[카테고리:] SSL

  • Rocky Linux 8.x 에서 Let’s encrypt 설치 및 SSL 발급받기

    OS 종류 및 버전에 따라 설치방법이 조금씩 다릅니다.

    본 내용은 Rocky Linux 8.x 에서 설치하는 방법을 다루었습니다.

    1. 패키지 다운로드

    # dnf -y install epel-release mod_ssl

    # dnf -y install certbot python3-certbot-apache

    2. 발급

    # certbot –apache
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Enter email address (used for urgent renewal and security notices)
     (Enter ‘c’ to cancel): (이메일 주소 입력)

    – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
    Please read the Terms of Service at
    https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017-w-v1.3-notice.pdf.
    You must agree in order to register with the ACME server. Do you agree?
    – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
    (Y)es/(N)o: Y

    – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
    Would you be willing, once your first certificate is successfully issued, to
    share your email address with the Electronic Frontier Foundation, a founding
    partner of the Let’s Encrypt project and the non-profit organization that
    develops Certbot? We’d like to send you email about our work encrypting the web,
    EFF news, campaigns, and ways to support digital freedom.
    – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
    (Y)es/(N)o: Y
    Account registered.

    Which names would you like to activate HTTPS for?
    – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
    1: www.sysdocu.com
    2: sub.sysdocu.com

    3: test.sysdocu.com

    – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
    Select the appropriate numbers separated by commas and/or spaces, or leave input
    blank to select all options shown (Enter ‘c’ to cancel): 1 2  // virtualhost 설정을 가져와 도메인을 출력합니다. 발급 원하는 도메인을 공백으로 구분하여 입력합니다. 통합 인증서가 아닌, 개별 인증서로 발급 받게 됩니다.
    Requesting a certificate for www.sysdocu.com and sub.sysdocu.com

    Successfully received certificate.
    Certificate is saved at: /etc/letsencrypt/live/www.sysdocu.com/fullchain.pem
    Key is saved at:         /etc/letsencrypt/live/www.sysdocu.com/privkey.pem
    This certificate expires on 2022-12-04.
    These files will be updated when the certificate renews.
    Certbot has set up a scheduled task to automatically renew this certificate in the background.

    Deploying certificate
    Successfully deployed certificate for www.sysdocu.com to /etc/httpd/conf/httpd-le-ssl.conf
    Successfully deployed certificate for sub.sysdocu.com to /etc/httpd/conf/httpd-le-ssl.conf
    Congratulations! You have successfully enabled HTTPS on https://www.sysdocu.com and https://sub.sysdocu.com

    – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
    If you like Certbot, please consider supporting our work by:
     * Donating to ISRG / Let’s Encrypt:   https://letsencrypt.org/donate
     * Donating to EFF:                    https://eff.org/donate-le
    – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

    아래 파일이 생성되면서 아파치 SSL 설정이 자동으로 이루어졌습니다.

    > /etc/httpd/conf/httpd-le-ssl.conf

    설정에 이상이 없는지 확인 후 아파치를 재시작 해줍니다.

    # apachectl configtest

    Syntax OK

    # systemctl restart httpd

    이제 https:// 프로토콜을 이용해 웹페이지 접근이 가능해졌습니다.

    3. 자동 갱신 설정

    발급된 인증서 유효기간은 3개월이며, 만료 1개월 전부터 갱신이 가능합니다.

    자동으로 발급받아질 수 있게 crontab 에 등록해 줍니다. (2개월에 한번씩 1일, 16일에 체크하여 갱신)

    # vi /etc/crontab

    01 00 01,16 */2 * root /usr/sbin/certbot renew

    ,

    출처 : https://sysdocu.tistory.com/1730

  • 무료 SSL Let’s encrypt certbot 설치하는 방법 – Linux CentOS

    무료 SSL Let’s encrypt certbot 설치하는 방법 – Linux CentOS

    1. 서버 설치하기 : 소스설치

    ~]# cd /usr/local

    ~]# yum install epel-release

    ~]# rpm -ivh https://rhel6.iuscommunity.org/ius-release.rpm

    ~]# yum install git python27 python27-devel python27-pip python27-setuptools python27-virtualenv python27-libs

    ~]# git clone https://github.com/certbot/certbot

    실행하기)

    ~]# cd /usr/local/certbot

    ~]# /usr/local/certbot/certbot-auto certonly

    오류가 난다면)

    ~]# chattr -i /usr/bin/gcc /usr/bin/g++

    이렇게 한 후 실행하고나서

    ~]# chmod 700 /usr/bin/gcc /usr/bin/g++;chattr +i /usr/bin/gcc /usr/bin/g++

    원복시키기

    2. 도메인 SSL  얻기

    ~]# ./certbot-auto certonly –server https://acme-v01.api.letsencrypt.org/directory \

    –rsa-key-size 4096 –agree-tos –email 당신의@이메일 \

    –webroot -w /home/계정이름/public_html/ \

    -d www.mydomain.com

    여기에서 수정해야 할 사항

    1) 당신의@이메일 : 도메인등록시 사용한 이메일을 기록한다.

    2)  webroot : /home/계정이름/public_html/ 수정할것

    3) 도메인명 : www.mydomain.com 나의 도메인 입력할 것

    이렇게 실행하면, 총 4개의 파일이 생성된다.

    /etc/letsencrypt/live/www.mydomaidn.com/ 폴더아래 생성된다.

    -agree-tos : ACME 서버에 가입자 동의서에 동의함

    -w : 웹 도메인의 루트패스

    -m : 이메일주소

    -d : SSL 발급 도메인명, 여러개를 한칸 뛰우고 나열해도 됨.

    주의) 하나의 도메인(같은 이름)에 대해서 1일 3회이상 발급테스트시 발급이 일시 제한됨.

    3. SSL 설정하기 – 아파치 apache

    cd /etc/httpd/conf.d

    vi ssl.conf

    <VirtualHost *:443>

    ErrorLog logs/ssl_error_log

    TransferLog logs/ssl_access_log

    LogLevel warn

    SSLEngine on

    SSLProtocol all -SSLv2

    SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES

    SSLCertificateFile /etc/letsencrypt/live/www.mydomain.com/cert.pem

    SSLCertificateKeyFile /etc/letsencrypt/live/www.mydomain.com/privkey.pem

    SSLCertificateChainFile /etc/letsencrypt/live/www.mydomain.com/chain.pem

    SSLCACertificateFile /etc/letsencrypt/live/www.mydomain.com/fullchain.pem

    DocumentRoot /home/폴더명/public_html

    ServerName www.mydomain.com

    </VirtualHost>

    위에 내용을 참고해서 기존에 내용과 비교한 다음 적절하게 부분 수정할 것.

    기존에 유료 SSL 을 이 무료 SSL 로 교체를 원할 경우 :

    ssl.conf 에서 기존에 사용하던 코드 삭제하고 위 내용으로 수정하면 SSL 교체되어 정상 동작함.

    그런후

    service httpd restart 하면 됨. 별도의 비밀번호 없음.

    주의) 443 포트 방화벽에서 막았을 경우 풀어줄 것.

    기존 SSL 교체완료

    4. 인증서 자동갱신하기

    4-1) 테스트해보기

    /usr/local/certbot/certbot-auto renew –dry-run

    테스트하면 성공여부가 나온다. 실제로 갱신은 안됨

    4-2) 실제 동작시켜보기

    /usr/local/certbot/certbot-auto renew

    실제 동작시키면 아직 기간이 안되었다는 문구가 나오고 종료됨

    4-3) cron 에 등록하여 자동으로 갱신시키기

    vi /etc/crontab

    00 8 1 * * root /usr/local/certbot/certbot-auto renew >> /var/log/ssl-renew.log

    service crond restart

    이 경우 매월1일 8:00 분에 모든 SSL 인증서를 판단하고 자동으로 갱신시킨다.

    결과는 /var/log/ssl-renew.log 에 기록된다.

    4-4) 인증서 삭제

    발급된 인증서의 삭제는 certbot-auto 명령을 이용하여 삭제해야 추후 다시 발급할 수 있으며,

    인증서 삭제명령후 인증서가 생성되었던 경로등을 확인해보면, 삭제한 도메인의 폴더가

    삭제된 것을 확인할 수 있습니다.

    ~#> /usr/local/certbot/certbot-auto delete -cert-name www.myadomin.com

    종합

    SSL인증서는 대부분 유료입니다.

    무료 SSL 중에 Amazon AWS SSL 인증서는 무료이지만 실제 설치하면

    SSL인증서를 연결하는 부분은 모두 유료서비스라서 결국 유료입니다.

    AWS SSL 을 아파치서버와 연결할 방법이 없기때문에 Amazon에서 제공하는
    Route53 이라는 DNS 관리툴로 연결을 해야 하는데,

    이 route53은 유료서비스입니다. 존파일에 갯수에 따라서 비용이 매월 나갑니다.

    그리고 이 route53으로 도메인을 설정했다면,
    내 도메인과 웹으로 연결시키기 위해서 CloudFront 서비스를

    추가로 신청해야 합니다. CloudFront 를 신청하면,

    기존에 www.mydomain.com 을 이 CloudFront 에서 지정한 80포트와 443포트(https)로

    연결시켜서 https SSL서비스가 동작하게 됩니다.

    문제는 아마존 CloudFront 역시 월 비용이 발생합니다.

    사용량에 따라서 발생하기때문에 부담이 되는 관리비용입니다.

    결국 아마존 무료 SSL 서비스는 실제 동작시키려면 아마존에 다른 유료서비스를

    이용해야 가능하고, 도메인도 아마존으로 DNS를 옮겨서 이용해야 하는

    불편함이 생깁니다. 아마존 SSL 이외에 모든 서비스는 유료이고 매월 비용이 카드로 지불됩니다.

    결국 아마존 무료 SSL 서비스는 유료서비스입니다. 대신에 아마존 AWS 서비스가

    비교적 저렴하기때문에 나중에 사용자가 늘어나면 이용해보는것도 좋습니다.

    아마존 CloudFront 서비스같은경우는 Ddos방어는 기본으로 제공되기때문에 보안등을 생각한다면

    무료 SSL과 이런 유료 서비스를 결합해서 내 도메인 DNS를 아예 아마존으로 옮겨서

    서비스받는것도 좋은 방식입니다. 또한 로드밸런싱서비스도 간단하고 쉽게 제공받을 수 있습니다.

    그러나, SSL만 필요한 경우라면 아마존 AWS서비스에 추가 매월 비용을 부담할 필요가 없습니다.

    무료로 이 인증서를 내 서버에 설치하고 운영하는게 제일 좋은 방법입니다.

    이 인증서는 Let’s Encrypt 라는 무료 SSL 인증서로

    wordpress 제작사등 많은 IT업계에 투자가 있어 비교적 안정된 인증서입니다.

    위에 방법대로 나의 리눅스 서버에서

    이렇게 쉽게  SSL을 무료로 설치가능합니다.

    또한 3개월의 만료기간을 자동으로 연장시키기때문에 계속 무료로 쓸 수 있습니다.

    적용환경

    CentOS6

    제공사이트 : https://certbot.eff.org/

    이 사이트에서 O/S별로 설치문서가 쉽게 제공중이기때문에 편리하게 설치가능합니다.

    작성일자 : 2018.12.24