차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판이전 판 | |||
tech:ssl_on_ubuntu [2016/11/16 07:31] – V_L | tech:ssl_on_ubuntu [2018/01/31 01:52] (현재) – V_L | ||
---|---|---|---|
줄 10: | 줄 10: | ||
| | ||
- | + | 자체 인증서는 | |
- | Self Signed Certificate(SSC)란 ? | + | |
- | 인증서(digital certificate)는 개인키 소유자의 공개키(public key)에 인증기관의 개인키로 전자서명한 데이타다. 모든 | + | |
- | IE, FireFox, Chrome 등의 Web Browser 제작사는 VeriSign 이나 comodo 같은 유명 ROOT CA 들의 인증서를 신뢰하는 CA로 미리 등록해 놓으므로 저런 기관에서 발급된 SSL 인증서를 사용해야 browser 에서는 해당 SSL 인증서를 신뢰할수 있는데 | + | |
- | OpenSSL 로 만든 ROOT CA와 SSL 인증서는 Browser가 모르는 기관이 발급한 인증서이므로 보안 경고를 발생시킬 것이나 테스트 사용에는 지장이 없다. | + | |
- | ROOT CA 인증서를 Browser에 추가하여 보안 경고를 발생시키지 않으려면 Browser 에 SSL 인증서 발급기관 추가하기 를 참고하자. | + | |
- | + | ||
- | CSR(Certificate Signing Request)은? | + | |
- | 공개키 기반(PKI)은 private key(개인키)와 public key(공개키)로 이루어져 있다. 인증서라고 하는 것은 내 공개키가 맞다고 인증기관(CA)이 전자서명하여 주는 것이며 | + | |
- | CSR 은 인증기관에 인증서 발급 요청을 하는 특별한 ASN.1 형식의 파일이며(PKCS# | + | |
- | SSL 인증서 발급시 CSR 생성은 Web Server 에서 이루어지는데 Web Server 마다 방식이 상이하여 사용자들이 CSR 생성등을 어려워하니 인증서 발급 대행 기관에서 개인키까지 생성해서 보내주고는 한다. | + | |
- | ROOT CA 인증서 생성 | + | |
- | openssl 로 root ca 의 개인키와 인증서를 만들어 보자 | + | |
- | CA 가 사용할 RSA key pair(public, | + | |
- | 2048bit 개인키 생성 | + | |
- | + | ||
- | openssl genrsa -aes256 -out / | + | |
- | + | ||
- | 개인키 분실에 대비해 AES 256bit 로 암호화한다. AES 이므로 | + | |
- | 개인키 권한 설정 | + | |
- | 보안 경고 | + | |
- | 개인키의 유출 방지를 위해 group 과 other의 permission 을 모두 | + | |
- | chmod 600 / | + | |
- | CSR(Certificate Signing Request) 생성을 위한 rootca_openssl.conf 로 저장 | + | |
- | rootca_openssl.conf | + | |
- | [ req ] | + | |
- | default_bits | + | |
- | default_md | + | |
- | default_keyfile | + | |
- | distinguished_name | + | |
- | extensions | + | |
- | req_extensions = v3_ca | + | |
- | + | ||
- | [ v3_ca ] | + | |
- | basicConstraints | + | |
- | subjectKeyIdentifier | + | |
- | ## | + | |
- | keyUsage | + | |
- | nsCertType | + | |
- | [req_distinguished_name ] | + | |
- | countryName | + | |
- | countryName_default | + | |
- | countryName_min | + | |
- | countryName_max | + | |
- | + | ||
- | # 회사명 입력 | + | |
- | organizationName | + | |
- | organizationName_default | + | |
- | + | ||
- | # 부서 입력 | + | |
- | # | + | |
- | # | + | |
- | + | ||
- | # SSL 서비스할 domain 명 입력 | + | |
- | commonName | + | |
- | commonName_default | + | |
- | commonName_max | + | |
- | 인증서 요청 생성 | + | |
- | root@vaslor: | + | |
- | You are about to be asked to enter information that will be incorporated | + | |
- | into your certificate request. | + | |
- | What you are about to enter is what is called a Distinguished Name or a DN. | + | |
- | There are quite a few fields but you can leave some blank | + | |
- | For some fields there will be a default value, | + | |
- | If you enter ' | + | |
- | ----- | + | |
- | Country Name (2 letter code) [KR]: | + | |
- | Organization Name (eg, company) [vaslor Inc]:vaslor Inc. | + | |
- | Common Name (eg, your name or your servers hostname) [vaslor' | + | |
- | 10년짜리 self-signed 인증서 생성 | + | |
- | -extensions v3_ca 옵션을 추가해야 한다. | + | |
- | + | ||
- | openssl x509 -req -days 3650 -extensions v3_ca -set_serial 1 -in / | + | |
- | -signkey / | + | |
- | + | ||
- | 제대로 생성되었는지 확인을 위해 인증서의 정보를 출력해 본다. | + | |
- | openssl x509 -text -in / | + | |
- | + | ||
- | + | ||
- | SSL 인증서 생성 | + | |
- | 위에서 생성한 root ca 서명키로 SSL 인증서를 발급해 보자 | + | |
- | SSL 호스트에서 사용할 RSA key pair(public, | + | |
- | 2048bit 개인키 생성 | + | |
- | + | ||
- | openssl genrsa -aes256 -out / | + | |
- | + | ||
- | Remove Passphrase from key | + | |
- | 개인키를 보호하기 | + | |
- | 개인키 pass phrase 제거 | + | |
- | cp / | + | |
- | + | ||
- | openssl rsa -in / | + | |
- | + | ||
- | 보안 경고 | + | |
- | 개인키의 유출 방지를 위해 group 과 other의 permission 을 모두 제거한다. | + | |
- | chmod 600 / | + | |
- | CSR(Certificate Signing Request) 생성을 위한 host_openssl.conf 로 저장 | + | |
- | host_openssl.conf | + | |
- | [ req ] | + | |
- | default_bits | + | |
- | default_md | + | |
- | default_keyfile | + | |
- | distinguished_name | + | |
- | extensions | + | |
- | ## 인증서 요청시에도 extension 이 들어가면 authorityKeyIdentifier 를 찾지 못해 에러가 나므로 막아둔다. | + | |
- | ## req_extensions = v3_user | + | |
- | + | ||
- | [ v3_user ] | + | |
- | # Extensions to add to a certificate request | + | |
- | basicConstraints = CA:FALSE | + | |
- | authorityKeyIdentifier = keyid, | + | |
- | subjectKeyIdentifier = hash | + | |
- | keyUsage = nonRepudiation, | + | |
- | ## SSL 용 확장키 필드 | + | |
- | extendedKeyUsage = serverAuth, | + | |
- | subjectAltName | + | |
- | [ alt_names] | + | |
- | ## Subject AltName의 DNSName field에 SSL Host 의 도메인 이름을 적어준다. | + | |
- | ## 멀티 도메인일 경우 *.vaslor.com 처럼 쓸 수 있다. | + | |
- | DNS.1 = www.vaslor.com | + | |
- | DNS.2 = vaslor.com | + | |
- | DNS.3 = *.vaslor.com | + | |
- | + | ||
- | [req_distinguished_name ] | + | |
- | countryName | + | |
- | countryName_default | + | |
- | countryName_min | + | |
- | countryName_max | + | |
- | + | ||
- | # 회사명 입력 | + | |
- | organizationName | + | |
- | organizationName_default | + | |
- | + | ||
- | # 부서 입력 | + | |
- | organizationalUnitName | + | |
- | organizationalUnitName_default | + | |
- | + | ||
- | # SSL 서비스할 domain 명 입력 | + | |
- | commonName | + | |
- | commonName_default | + | |
- | commonName_max | + | |
- | SSL 인증서 요청 | + | |
- | root@vaslor: | + | |
- | You are about to be asked to enter information that will be incorporated | + | |
- | into your certificate request. | + | |
- | What you are about to enter is what is called a Distinguished Name or a DN. | + | |
- | There are quite a few fields but you can leave some blank | + | |
- | For some fields there will be a default value, | + | |
- | If you enter ' | + | |
- | ----- | + | |
- | Country Name (2 letter code) [KR]: | + | |
- | Organization Name (eg, company) [vaslor Inc]: | + | |
- | Common Name (eg, your name or your servers hostname) [vaslor.com]: | + | |
- | 5년짜리 vaslor.com 용 SSL 인증서 발급 (서명시 ROOT CA 개인키로 서명) | + | |
- | openssl x509 -req -days 1825 -extensions v3_user -in / | + | |
- | -CA / | + | |
- | -CAkey | + | |
- | -out / | + | |
- | 제대로 생성되었는지 확인을 위해 인증서의 정보를 출력해 본다. | + | |
- | openssl x509 -text -in / | + | |
- | + | ||
- | + | ||
- | =====SSL===== | + | |
- | + | ||
- | Setting up SSL with Ubuntu 8.10 is a simple process but it does have a few gotchas that you need to be aware of. The setup has changed from 8.04. One issue is that the +CompatEnvVars is no longer used as it created a bug in 8.10 and you will have to enable the default-ssl site to get everything working. | + | |
- | + | ||
- | First, log on to your server | + | |
- | + | ||
- | sudo apt-get install apache2 | + | |
- | + | ||
- | Change to the / | + | |
- | + | ||
- | cd / | + | |
- | ls | + | |
- | cd / | + | |
- | ls | + | |
- | + | ||
- | Now, install and enable SSL: | + | |
- | + | ||
- | sudo a2enmod ssl | + | |
- | sudo / | + | |
- | + | ||
- | Change to the default webserver directory, and create a simple web page: | + | |
- | cd /var/www | + | |
- | sudo vim index.html | + | |
- | + | ||
- | Add the following content: | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | </ | + | |
- | < | + | |
- | < | + | |
- | </ | + | |
- | </ | + | |
- | + | ||
- | Save and exit. On your own local computer, open a tab or window for your web browser. | + | |
- | + | ||
- | http:// | + | |
- | + | ||
- | You should be able to view your web page. Now, you’ll want to encrypt your site. Create the server encryption keys: | + | |
- | + | ||
- | cd / | + | |
- | sudo openssl genrsa -des3 -out server.key 1024 | + | |
- | + | ||
- | Use this set of keys to create a certificate request: | + | |
- | + | ||
- | sudo openssl req -new -key server.key -out server.csr | + | |
- | + | ||
- | When asked to input data, use your imagination to create something appropriate. | + | |
- | + | ||
- | sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt | + | |
- | + | ||
- | Install the key and certificate: | + | |
- | + | ||
- | sudo cp server.crt / | + | |
- | sudo cp server.key / | + | |
- | + | ||
- | Open the “defaults” file for editing: | + | |
- | + | ||
- | cd / | + | |
- | sudo vim default-ssl | + | |
- | + | ||
- | This file is basically set up but you will want to uncomment | + | |
- | + | ||
- | SSLEngine on | + | |
- | SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire | + | |
- | SSLCertificateFile / | + | |
- | SSLCertificateKeyFile / | + | |
- | + | ||
- | The port 443 is enabled when you use SSL so that is ready to go. | + | |
- | + | ||
- | Enable the default SSL site: | + | |
- | sudo a2ensite default-ssl | + | |
- | + | ||
- | If you do not enable the default-ssl you will get this error: | + | |
- | “ssl_error_rx_record_too_long apache” | + | |
- | + | ||
- | Restart Apache. | + | |
- | + | ||
- | sudo / | + | |
- | + | ||
- | That should do it. | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | * 출처: [[http:// | + | |
- | + | ||
- | ^ 누구나 수정하실 수 있습니다. | + | |