Ssl

From 탱이의 잡동사니
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Overview

SSL 관련 통신에서 서버를 운영하기 위해서는 반드시 SSL 인증서가 필요하다. 여기에서는 SSL 인증서의 종류와 설정 방법을 설명한다.

SSL

SSL(Secure Socket Layer) 프로토콜은, 처음에 Netscape 사에서 웹서버와 브라우저 사이의 보안을 위해 만들었다. SSL은 Certificate Authority(CA)라 불리는 서드 파티로부터 서버와 클라이언트의 인증을 하는데 사용된다.

다음은 간단한 SSL 통신 과정이다.

Server : SSL 로 암호화된 페이지를 요청한다.(일반적으로 https://가 사용된다.)

Client : Publick Key 를 인증서와 함께 전송한다.

Client : 전송된 인증서를 자신의 인증 CA(인반적으로 trusted root CA라고 불림)로부터 서명된 것인지 확인한다.
(Internet Expolore나, Netscape 와 같은 웹브라우저에는 이미 Verisign, Thawte 와 같은 널리 알려진 root CA 의 인증서가 설치되어 있다.) 
또한 날짜가 유효한지, 그리고 인증서가 접속하려는 사이트와 관련되어 있는지 확인한다.

Client :  Public Key 를 사용해서 랜덤 대칭 암호화키(Random symmetric encryption key)를 비롯한 URL, http 데이터들을 암호화해서 전송한다.

Server : Private Key 를 이용해서 랜덤 대칭 암호화키와 URL, http 데이터를 복호화한다.

Server : 요청받은 URL에 대한 응답을 Client로부터 받은 랜덤 대칭 암호화키를 이용하여 암호화해서 Client로 전송한다.

Client : 대칭 키를 이용해서 http 데이터와 html 문서를 복호화하고, 화면에 정보를 뿌려준다.

공인 인증 SSL 인증서

자가 인증 SSL 인증서

10년 짜리 자가 인증 SSL 인증서 만들기. <source lang=bash> pi@raspberrypi /etc/pki $ sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout ./postfix.key -out ./postfix.crt Generating a 2048 bit RSA private key .........................+++ ...........+++ writing new private key to './postfix.key'


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 '.', the field will be left blank.


Country Name (2 letter code) [AU]:KR State or Province Name (full name) [Some-State]:pchero Locality Name (eg, city) []:Seoul Organization Name (eg, company) [Internet Widgits Pty Ltd]:pchero Organizational Unit Name (eg, section) []:pchero Common Name (e.g. server FQDN or YOUR name) []:pchero Email Address []:test@example.com </source>

ssl_error_rx_record_too_long

APACHE 에 RSA:2048 옵션으로 생성한 SSL 인증서 설정시, Firefox 에서 정상적으로 접속이 안되는 현상이 나타났다.

    Secure Connection Failed

    An error occurred during a connection to pchero21.com. SSL received a record that exceeded the maximum permissible length. 
    (Error code: ssl_error_rx_record_too_long)

    The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
    Please contact the website owners to inform them of this problem.

RSA:1024 옵션으로 생성한 SSL 인증서 사용 후, 문제가 해결되었다.

Create ssl cli only

-subj 옵션을 사용하면 필수 입력 항목들에 값을 지정할 수 있다.

$ sudo openssl req -subj '/CN=US/O=Jade project/C=US' -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -out server.crt

PEM file

key, crt 파일을 따로 관리하는 것이 아니라 하나의 파일에 모아서 관리하는 것도 가능하다. 이런 파일을 pem 파일이라고 한다. 다음과 같이 생성한다. 원문은 이곳<ref>http://stackoverflow.com/questions/991758/how-to-get-an-openssl-pem-file-from-key-and-crt-files</ref>에서 확인할 수 있다.

<source lang=bash> $ cat server.crt server.key > server.includesprivatekey.pem </source>

References

<references/>