MacOS로 인증서 만들기

8902 단어 ssltech
지금까지 이 터미널(macOS)에서 Let's Encerypt를 사용하여 SSL 인증서를 발행하고 싶어서 필기를 해 봤습니다.
2010/12/01 추기
  • 청결하게 설치된 맥OS 빅수어(11.0.1) 환경에서도 문제certbot가 없다.
  • 후술한emacs 관련 오류가 발생하지 않습니다.
  • 전제 조건

  • Macbook Pro(macOS Catalina)
  • Homebrew
  • 가 설치되어 있음

    Certbot 설치


    명령줄에 Let's Encerypt를 생성하는 인증서Certbot를 설치합니다.
    brew install certbot
    
    # version
    certbot --version
    certbot 1.9.0
    
    ※ 이 환경에서 도중에emacs 관련 오류가 발생했습니다.
    ==> Installing emacs
    ==> Pouring emacs-27.1.catalina.bottle.tar.gz
    ==> Caveats
    To have launchd start emacs now and restart at login:
      brew services start emacs
    Or, if you don't want/need a background service you can just run:
      emacs
    ==> Summary
    🍺  /usr/local/Cellar/emacs/27.1: 4,009 files, 104.0MB
    Removing: /usr/local/Cellar/emacs/26.3... (3,986 files, 101.4MB)
    ==> Checking for dependents of upgraded formulae...
    Error: No such file or directory - /usr/local/Cellar/emacs/26.3
    
    아래의 대응 방식을 통해 제거한다.
    # すでに emacs は入っていたため依存関係を無視して一旦アンインストール
    brew uninstall --ignore-dependencies emacs
    
    # 再度 certbot をインストール
    # `install` だと `To reinstall 1.9.0, run `brew reinstall certbot` となったので `reinstall` を使用
    brew reinstall certbot
    

    증명서를 발행하다


    1. 인증서 발급 명령 실행


    # 発行したいドメインを指定する
    # ex: example.com
    sudo certbot certonly --manual --domain example.com
    Password: # パスワード入力
    

    2. 대화식 질문에 답하기


    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Plugins selected: Authenticator manual, Installer None
    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.pdf. You must
    agree in order to register with the ACME server at
    https://acme-v02.api.letsencrypt.org/directory
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    (A)gree/(C)ancel: A    # 利用規約に同意する
    
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    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: N         # メールアドレスを公開しないにしておく
    Obtaining a new certificate
    Performing the following challenges:
    http-01 challenge for example.com
    
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NOTE: The IP of this machine will be publicly logged as having requested this
    certificate. If you're running certbot in manual mode on a machine that is not
    your server, please ensure you're okay with that.
    
    Are you OK with your IP being logged?
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    (Y)es/(N)o: Y        # IPアドレスのロギング
    
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Create a file containing just this data:
    
    # ランダムな文字列1
    
    And make it available on your web server at this URL:
    
    http://example.com/.well-known/acme-challenge/# ランダムな文字列2
    
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Press Enter to Continue
    

    3. 도메인 이름 소유 확인


    아래의 대응을 실시하여 발행하고자 하는 example.com역을 확인한다.
  • http://example.com/.well-known/acme-challenge/ 아래 ランダムな文字列2의 파일 이름으로 파일을 설정하고 ランダムな文字列1를 내용으로 저장합니다.
  • 지정된 URL에 액세스하여 파일에 액세스할 수 있는지 확인합니다.
  • 터미널로 돌아가 Enter를 누릅니다.
  • 4. 생성된 인증서 파일 확인


    Waiting for verification...
    Cleaning up challenges
    
    IMPORTANT NOTES:
     - Congratulations! Your certificate and chain have been saved at:
       /etc/letsencrypt/live/example.com/fullchain.pem
       Your key file has been saved at:
       /etc/letsencrypt/live/example.com/privkey.pem
       Your cert will expire on 2021-01-18. To obtain a new or tweaked
       version of this certificate in the future, simply run certbot
       again. To non-interactively renew *all* of your certificates, run
       "certbot renew"
     - Your account credentials have been saved in your Certbot
       configuration directory at /etc/letsencrypt. You should make a
       secure backup of this folder now. This configuration directory will
       also contain certificates and private keys obtained by Certbot so
       making regular backups of this folder is ideal.
     - 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
    
    성공하면 다음과 같은 파일을 생성합니다.
  • 서버 인증서와 중간 CA 인증서를 결합한 인증서/etc/letsencrypt/live/example.com/fullchain.pem
  • 기밀 키/etc/letsencrypt/live/example.com/privkey.pem
  • 참고로 /etc/letsencrypt/live/example.com/ 아래에 다른 서류가 있습니다.
  • 서버 인증서/etc/letsencrypt/live/example.com/cert.pem
  • 중간 CA 인증서/etc/letsencrypt/live/example.com/chain.pem
  • 5. 서버에 인증서 설정 및 동작 확인


    위에서 생성한 인증서 파일을 서버에 설정하여 작업을 검사합니다.
    예:nginx에서 설정합니다.
    SSL 관련 디렉토리는 각각 다음 파일을 설정하면 됩니다.
  • ssl_certificatecert.pem
  • ssl_trusted_certificatefullchain.pem
  • ssl_certificate_keyprivkey.pem
  • 참고 자료

  • https://neos21.hatenablog.com/entry/2019/03/11/080000
  • 좋은 웹페이지 즐겨찾기