85
Thiết lập và triển khai Secure Socket Layer ( SSL )

Ssl it-slideshares.blogspot.com

Embed Size (px)

DESCRIPTION

Ssl more from http://it-slideshares.blogspot.com and japanese-zen-garden.blogspot.com

Citation preview

Page 1: Ssl it-slideshares.blogspot.com

Thiết lập và triển khai Secure Socket Layer

(SSL)

Page 2: Ssl it-slideshares.blogspot.com

Thực hiện :Trần Ngọc SơnNguyễn Hữu

TìnhHuỳnh Công

TânLê Minh Vương

GVHD: TS Phạm Văn Tính

Page 3: Ssl it-slideshares.blogspot.com

1. Giới Thiệu Tổng Quan SSL2. Triển Khai SSL trên Apache23. Triển Khai SSL trên Tomcat64. Triển Khai SSL trên IIS5. Demo

Nôi Dung

Page 4: Ssl it-slideshares.blogspot.com

Giới thiệu Tổng Quan

Page 5: Ssl it-slideshares.blogspot.com

Sercure Socket Layer (SSL) hiện nay la giao thưc bao mât rât phổ biên trên Internet trong cac hoat đông thương mai điện tư (E-Commerce). Việt Nam đang trên đương hôi nhâp với nên công nghệ thông tin thê giới, nên nay mai, cac hoat đông giao dich trên mang ơ Việt Nam cung se diên ra sôi nổi, khi đo vân đê bao mât trơ nên quan trong, việc triên khai SSL la điêu thiêt yêu.

Tuy nhiên đên nay vân ít trang Web nao ơ Việt Nam sư dung SSL trong cac giao dich cua minh

Page 6: Ssl it-slideshares.blogspot.com

Chưng thưc (certificate) la nhưng tai liệu co chưa thông tin cân thiêt cho qua trinh thiêt lâp đinh danh (identity) qua mang, qua trinh đo con goi la qua trinh xac thưc (authentication).

Chưng thưc cho phep may chu (server) va may khach (client) xac thưc lân nhau trước khi thiêt lâp kêt nôi. Co hai loai chưng thưc la chưng thưc may khach (client certificate) va chưng thưc may chu (server certificate).

Ngoai ra con co môt đôi tac thư ba lam dich vu cung câp va kiêm tra chưng thưc cho ca hai bên, đo la Certification Authority (CA), tât nhiên CA chi lam việc đươc khi ca hai bên đêu tin tương vao minh.

Chưng thưc điện tư (Digital Certificate)

Page 7: Ssl it-slideshares.blogspot.com

Nhận danh người đang giao tiếp với ( Website, Customer).

Credit Card Numbers thì được mã hóa và không thể đánh cắp.

Dữ liệu gửi và nhận không thể sửa đổi hoặc giả mạo.

Lợi ích của SSL đối với những ứng dụng

Page 8: Ssl it-slideshares.blogspot.com

2 bên tham gia , client và server không biết về nhau.

Muốn để chứng thực mỗi người khác.Client chứng thực server.

E.g : “Am I talking to the real amazon.com server?”Server chứng thực client.

Muốn giữ bí mật và toàn vẹn thông tin khi trao đổi dữ liệu ở cả 2 hướng.

SSL/TLS giải quyết vấn đề gì?

Page 9: Ssl it-slideshares.blogspot.com

Môt sô công ty chuyên lam dich vu CA: VeriSign (www.verisign.com) Thawte Consulting (www.thawte.com) Entrust Technologied (www.entrust.com) Keywitness (www.keywitness.ca)

Page 10: Ssl it-slideshares.blogspot.com

Vấn đề : Man in the Middle Attacks

Client

Attacker

Server

•Một mình public-key cryptography không đưa ra được cơ chế chứng thực tốt.•Kẻ tấn công có thể giả lập server

Page 11: Ssl it-slideshares.blogspot.com

Vấn đề : Man in the Middle Attacks

Attacker

Server

Client•Kẻ tấn công co thể không xuất hiện giống Server.•Kẻ tấn công hoặt đông như “man in the middle”

Page 12: Ssl it-slideshares.blogspot.com

Giao thưc SSL năm giưa tâng ưng dung (application layer) thương la HTTP va tâng chuyên vân (transport layer) thương la TCP/IP. SSL dung ky thuât ma hoa công khai đê ma hoa tât ca liên lac giưa server/client.

SSL đươc giới thiệu bơi Netscape va mau chong thanh chuân cho cac giao dich trưc tuyên, dân đên sư hinh thanh chuân giao thưc Transport Layer Security (TLS) đang đươc phat triên bơi Internet Engineering Task Force.

Phương phap hoat đông cua SSL

Page 13: Ssl it-slideshares.blogspot.com

1. Kêt nôi tư client đên server đươc thưc hiện băng giao thưc HTTPS (HTTP+SSL)

2. Server kí khoa công khai (public key) băng khoa bí mât (private key) cua minh va gưi cho client

3. Client dung khoa công khai cua server đê xac nhân đung server đang liên lac

4. Client kiêm tra xem co CA nao đa kí vao khoa. Nêu không client se hoi ngươi dung xem co nên tin tương vao server không

5. Client sinh ra môt khoa bât đôi xưng (asymmetric key) cho phiên giao dich, khoa nay đươc ma hoa băng khoa công khai cua may chu va gưi ngươc lai. Khoa nay cung se

đươcdung đê ma hoa tât ca cac thông tin sau nay.

Sư hoat đông cua SSL 2.0

Page 14: Ssl it-slideshares.blogspot.com

SSL 3.0 bổ sung thêm cho SSL 2.0 băng cach hô trơ cho chưng thưc may khach (client certificate), giup server co thê nhân diện ngươc lai client. SSL 3.0 hoat đông như SSL 2.0 , nhưng sau khi client đa xac thưc server , đên lươt server se kiêm tra ngươc lai client.

SSL 3.0

Page 15: Ssl it-slideshares.blogspot.com

SSL 3.0 Handshake Overview

15

Client ServerClientHello: client_version, client_random, client_cipher_list

ServerHello: server_version, server_random, server_cipher_list

ServerCertificate: server_certificate_list

ClientKeyExchange: {pre_master_secret}KSChangeCipherSpec: client_cipher Finished: MAC<master_secret, all messages>

ChangeCipherSpec: server_cipher

Finished: MAC<master_secret, all messages>

compute session keys

compute session keys

Page 16: Ssl it-slideshares.blogspot.com
Page 17: Ssl it-slideshares.blogspot.com

Triên Khai SSL

Page 18: Ssl it-slideshares.blogspot.com

APACHE 2

Page 19: Ssl it-slideshares.blogspot.com

Kiểm tra Apache2 đã được cài đặt trên hệ thống chưa ?

sudo dpkg --get-selections | grep apache2 Cài đặt Apache2

sudo apt-get install apache2 Sau đó bật mod ssl

sudo a2enmod ssl Bật site default ssl

sudo a2ensite default-ssl

Page 20: Ssl it-slideshares.blogspot.com

Tạo server encryption keyssudo openssl genrsa -des3 -out server.key 1024

Tạo certificate request sudo openssl req -new -key server.key -out

server.csr Tạo self-signed certificate sudo openssl x509 -req -days 365 -in server.csr -

signkey server.key -out server.crt

Page 21: Ssl it-slideshares.blogspot.com

Sau đó copy file server.crt vào thư mục /etc/ssl/certs/, và file server.key vào thư mục /etc/ssl/private/

sudo cp server.crt /etc/ssl/certs/ sudo cp server.key /etc/ssl/private/ Vào file cấu hình /etc/apache2/sites-available/default-

ssl sửa 2 dòng sau: SSLCertificateFile    /etc/ssl/certs/ssl cert snakeoil.pem

SSLCertificateKeyFile /etc/ssl/private/ssl cert snakeoil.key Thành :

SSLCertificateFile    /etc/ssl/certs/server.crtSSLCertificateKeyFile /etc/ssl/private/server.key

Page 22: Ssl it-slideshares.blogspot.com

Sau đó restart lại apache2 sudo /etc/init.d/apache2 restart Mở trình duyệt web browser gõ: https://localhost, hoàn tất quá trình triển

khai.

Page 23: Ssl it-slideshares.blogspot.com

TOMCAT

Page 24: Ssl it-slideshares.blogspot.com

Quá trình triển khai ssl trên tomcat6 Kiểm tra đã cài đặt jdk trên hệ thống chưa? sudo dpkg --get-selections | grep sun-java Nếu chưa cài đặt, tiến hành cài đặt sudo apt-get install sun-java6-jdk Sau đo tiến hành cài đặt tomcat6 sudo apt-get install tomcat6 tomcat6-admin tomcat6-example Để truy xuất vào manager application và host-manager chúng ta cần

định nghĩa user với role “manager” , “admin” trong file /etc/tomcat6/tomcat-users.xml như sau:<role rolename=”admin”/><role rolename=”manager”/>

<user username=”username” password=”password” roles=”admin”/> <user username=”username” password=”password”

roles=”manager”/>

Page 25: Ssl it-slideshares.blogspot.com

Tạo certificate

keytool -genkey -alias tomcat -keyalg RSA -keystore tomcat.key

file /etc/tomcat6/server.xml Uncomment các dòng sau:

<!--

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"

maxThreads="150" scheme="https" secure="true"

clientAuth="false" sslProtocol="TLS" />

--> Sau đó thêm dòng sau:

keystoreFile=“/path/to/keystore” keystorePass=“passCreateKey”.

Sau đó restart lại tomcat

sudo /etc/init.d/tomcat6 restart Mở trình duyệt gõ: https://localhost:8443

Page 26: Ssl it-slideshares.blogspot.com

IIS

Page 27: Ssl it-slideshares.blogspot.com

Tự tạo Certificate cho mình (self-signed certificate)

Dùng Certificate của các tổ chức CA như VeriSigns

Triển khai trên IIS

Page 28: Ssl it-slideshares.blogspot.com

openssl.exe: tải ở http://www.openssl.org

self-signed certificate

Page 29: Ssl it-slideshares.blogspot.com

Tạo khóa riêng X509 cho CA, mã hóa dạng Base64 – Mục đích là sẽ dùng khóa riêng này kí nhận cho code signing certificate. Khi tạo, cần cung cấp mật khẩu cho khóa riêng này.Lệnh: genrsa -des3 -out MyCA.key 1024

Tạo chứng chỉ X509 cho CA có chứa public key, mã hóa dạng Base64 – Bạn cung cấp các thông tin cho CA, bao gồm tên đại diện cho CA, mã quốc gia, tên thành phố, email và mật khẩu của khóa riêng đã tạo ở trên.Lệnh: req -new -config openssl.cfg -x509 -

days 365 -key MyCA.key -out MyCA.crt

Tạo Certificate với Openssl

Page 30: Ssl it-slideshares.blogspot.com

Tạo khóa riêng X509 sử dụng để kí code – Thao tác tương tự như tạo khóa cho CA ở trên. Lệnh: genrsa -des3 -out MyServer.key 1024

Tạo một yêu cầu kí nhận (certificate signing request) cho chứng chỉ Lệnh: req -config openssl.cfg -out

MyServer.csr -key MyServer.key –new

Page 31: Ssl it-slideshares.blogspot.com

Tạo chứng chỉ public X509 để kí code từ yêu cầu ở trên, kèm thêm các khóa public của CA và sử dụng thông tin của CA để kí nhận – Kết quả sẽ chứa trong tệp myServer.cer. Đây chính là chứng chỉ tự kí, self-signed certificate.Lệnh: x509 -CAcreateserial -CAserial

MyCA.srl -in MyServer.csr -days 370 -req -extfile openssl.cfg -extensions v3_req -CA MyCA.crt -CAkey MyCA.key -out MyServer.crt

Page 32: Ssl it-slideshares.blogspot.com

Tạo tệp dạng .pfx định dạng PKCS-12 (thông tin trao đổi cá nhân). Lệnh: pkcs12 -export -in MyServer.crt -

inkey MyServer.key -out MyServe.pfx

Page 33: Ssl it-slideshares.blogspot.com

Như đã đề cập, để hệ thống Windows Vista tin cậy ứng dụng bạn kí bằng chứng chỉ vừa tạo, bạn cần cài đặt chứng chỉ public key của CA vào hệ thống tại vị trí LocalComputer\Trusted Root Certification Authorities. Nếu làm tương tự như ví dụ trên, chứng chỉ của CA được chứa trong tệp VistaCA.cer.

Dưới đây là cách cài đặt chứng chỉ vào hệ thống sử dụng công cụ Microsoft Management Console (mmc.exe).

• Khởi động trình "mmc.exe" từ trình đơn Start/Run:

Cai đặt chưng chi CA tư tao cho Windows Vista/7

Page 34: Ssl it-slideshares.blogspot.com

mmc

Page 35: Ssl it-slideshares.blogspot.com

Bổ sung snap-in có tên "Certificates" cho "Local Computer"

Page 36: Ssl it-slideshares.blogspot.com
Page 37: Ssl it-slideshares.blogspot.com
Page 38: Ssl it-slideshares.blogspot.com

Chọn chức năng "Import" để cài đặt chứng chỉ public key của CA vào "Trusted root certification authorities

Page 39: Ssl it-slideshares.blogspot.com

Chạy IIS Manager Add Certificate vào Setup cho trang web muốn bảo mật bằng SSL

Bao mât trang web IIS băng SSL

Page 40: Ssl it-slideshares.blogspot.com

1. Tạo file Request Certificate2. Xin SSL Certificate từ VeriSign.com3. Cấu hình Trusted Root Certification Authority4. Import SSL Certificate cho Web Server5. Kiểm tra kết quả

Bao mât website với SSL certificate Trial cua VeriSign.com

Page 41: Ssl it-slideshares.blogspot.com

Logon Administrator, mở Internet Information Services (IIS) Manager, bung Web Site, chuột phải Default Web Site, chọn Properties- Hộp thoại Default Web Site Properties, qua tab Directory Security, chọn Server Certificate

Tạo Request Certificate

Page 42: Ssl it-slideshares.blogspot.com

Hộp thoại Welcome to the Web Server Certificate Wizard, chọn Next

Page 43: Ssl it-slideshares.blogspot.com
Page 44: Ssl it-slideshares.blogspot.com
Page 45: Ssl it-slideshares.blogspot.com
Page 46: Ssl it-slideshares.blogspot.com
Page 47: Ssl it-slideshares.blogspot.com
Page 48: Ssl it-slideshares.blogspot.com
Page 49: Ssl it-slideshares.blogspot.com
Page 50: Ssl it-slideshares.blogspot.com
Page 51: Ssl it-slideshares.blogspot.com
Page 52: Ssl it-slideshares.blogspot.com
Page 53: Ssl it-slideshares.blogspot.com

Copy nội dung file certeq.txt

2. Xin SSL Certificate từ VeriSign.com

Page 54: Ssl it-slideshares.blogspot.com

Mở Brower, truy cập địa chỉ http://www.verisign.com,chọn Free SSL Trial

Page 55: Ssl it-slideshares.blogspot.com

- Trong cửa sổ Free SSL Trial Certificate, nhập đằy đủ thông tin (*: thông tin bắt buộc), chọn Continue

Page 56: Ssl it-slideshares.blogspot.com
Page 57: Ssl it-slideshares.blogspot.com
Page 58: Ssl it-slideshares.blogspot.com

Trong ô Select Server Platform, chọn Microsoft. Trong ô Select Version, chọn IIS 6.0. Dán nội dung file certreq.txt vào ô Paste Certificate Signing Request (CSR), optained from your server

Page 59: Ssl it-slideshares.blogspot.com
Page 60: Ssl it-slideshares.blogspot.com
Page 61: Ssl it-slideshares.blogspot.com
Page 62: Ssl it-slideshares.blogspot.com
Page 63: Ssl it-slideshares.blogspot.com

3. Cấu hình Trusted Root Certification Authority

Page 64: Ssl it-slideshares.blogspot.com
Page 65: Ssl it-slideshares.blogspot.com
Page 66: Ssl it-slideshares.blogspot.com
Page 67: Ssl it-slideshares.blogspot.com
Page 68: Ssl it-slideshares.blogspot.com
Page 69: Ssl it-slideshares.blogspot.com
Page 70: Ssl it-slideshares.blogspot.com
Page 71: Ssl it-slideshares.blogspot.com
Page 72: Ssl it-slideshares.blogspot.com
Page 73: Ssl it-slideshares.blogspot.com
Page 74: Ssl it-slideshares.blogspot.com
Page 75: Ssl it-slideshares.blogspot.com
Page 76: Ssl it-slideshares.blogspot.com
Page 77: Ssl it-slideshares.blogspot.com

Mở (IIS) Manager, chuột phải Default Web Site chọn Properties- Trong cửa sổ Default Web Site Properties, qua tab Directory Security, chọn Server Certificate

Page 78: Ssl it-slideshares.blogspot.com
Page 79: Ssl it-slideshares.blogspot.com
Page 80: Ssl it-slideshares.blogspot.com
Page 81: Ssl it-slideshares.blogspot.com
Page 82: Ssl it-slideshares.blogspot.com
Page 83: Ssl it-slideshares.blogspot.com
Page 84: Ssl it-slideshares.blogspot.com
Page 85: Ssl it-slideshares.blogspot.com