Skip to content

Instantly share code, notes, and snippets.

@bbirec
Last active April 29, 2016 04:36
Show Gist options
  • Save bbirec/68f9119326c3bcfe0d26 to your computer and use it in GitHub Desktop.
Save bbirec/68f9119326c3bcfe0d26 to your computer and use it in GitHub Desktop.
SSL 구입

SSL 인증서 구입

SSL을 먼저 구입한다. 구입할수 있는 다른 여러 사이트가 있는데, https://www.ssls.com 에서 싸게 구입할 수 있다. 결제를 완료하면 CSR파일을 업로드 해라고 나오는데 로컬 컴퓨터에서 생성해서 올려야 한다.

CSR파일 만들기

Private key 만들기

private key를 만든다. pass phrase는 바로 복호화한 server.key파일을 만들것 이기 때문에 아무 패스워드나 넣는다.

$ openssl genrsa -des3 -out server.pass.key 2048
Generating RSA private key, 2048 bit long modulus
.........+++
................................+++
e is 65537 (0x10001)
Enter pass phrase for server.pass.key:

이전에 입력했던 pass phrase를 넣어서 복호화한 server.key를 만든다.

$ openssl rsa -in server.pass.key -out server.key
Enter pass phrase for server.pass.key:
writing RSA key

CSR 만들기

SSL구매 사이트에 올릴 CSR을 만든다. Common Name에는 사용할 domain을 적는다. www.dabangapp.com으로 적으면 dabangapp.com까지 자동으로 포함되므로 www.dabangapp.com을 적는다.

$ openssl req -nodes -new -key server.key -out server.csr
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]:Seoul
Locality Name (eg, city) []:Seoul
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Station3, Inc.
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:www.dabangapp.com
Email Address []:[email protected]

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

이렇게 하면 server.keyserver.csr파일이 만들어 졌다. server.key는 private key이기 때문에 외부에 유출 되지 않게 조심해야 한다.

인증서(CRT) 받기

server.csr파일을 업로드 하면 domain 소유자인지 체크과정을 거치고 인증서 www_dabangapp_com.crt를 이메일로 보내준다. server.key파일과 www_dabangapp_com.crt을 가지고 각자 웹서버 환경에 맞게 설치하면 된다.

@bbirec
Copy link
Author

bbirec commented Apr 11, 2016

AWS ElasticBeanstalk에 SSL등록 방법

$ aws iam upload-server-certificate --server-certificate-name upload-images-dabangapp-com --certificate-body file://server.crt --private-key file://server.key
{
    "ServerCertificateMetadata": {
        "ServerCertificateId": "ASCAIEWZGADYQAOE3YR72", 
        "ServerCertificateName": "upload-images-dabangapp-com", 
        "Expiration": "2019-04-11T23:59:59Z", 
        "Path": "/", 
        "Arn": "arn:aws:iam::***************************************************", 
        "UploadDate": "2016-04-11T05:05:56.060Z"
    }
}

파라메터 중에 인증서 이름 부분을 바꿔주면 된다. 이렇게 한뒤 Load balancer 설정 부분에서 선택 가능하다.

@bbirec
Copy link
Author

bbirec commented Apr 29, 2016

https://www.geocerts.com/ssl_checker 에서 제대로 인증서가 설치되었는지 확인 할 수 있다.

Certificate Chain Complete 항목이 제대로 되어 있지 않는 경우, 오래된 모바일 기기에서 신뢰할수 없는 기관에 의해 발급된 인증서라는 오류가 나온다.
따라서 아래처럼 Root CA를 붙여서 bundle 인증서로 만든다.

$ cat AddTrustExternalCARoot.crt COMODORSAAddTrustCA.crt COMODORSADomainValidationSecureServerCA.crt  www_dabangapp_com.crt > www_dabangapp_com-bundle.crt

또는 다른 툴을 이용해서 ssl을 생성할수 있다.
https://certificatechain.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment