반응형
Xampp에 OpenSSL 설치하기.md

윈도우버젼 Xampp에 OpenSSL 설치하기

윈도우 버젼의 Xampp를 사용하고 있습니다.

CloudFlare 의 무료 SSL 기능으로 https 웹사이트를 구현하려고 합니다.

많은 자료가 있기는 했는데 딱 맞아떨어지는 자료를 못 찾아서 한참을 해매었다는..ㅠㅠ.


Xampp 에서 SSL 접속 설정하기

  • CloudFlare의 무료 FULL SSL서비스를 사용하기 위해선 일단 어떤것이든 인증서를 가지고 있어야합니다.
  • 유료/무료 인증서를 받아도 좋지만, 그냥 간편하게 자체인증서만으로도 구현이 가능하므로 지금은 자체인증서를 만들어 보도록 하겠습니다.
  1. 윈도우 도스 프롬프트를 실행 (이후 명령어들은 도스프롬프트에서 입력)

  2. 윈도우에 설치된 Xampp에서 Apache\bin 폴더로 이동

    cd /D D:\xampp\apache\bin

  3. 편한 작업을 위해서 openssl 매개변수로 환경변수를 설정

    set OPENSSL_CONF=D:\xampp\apache\conf\openssl.cnf

    set RANDFILE=C:\Temp\.rnd

    ※ C:\Temp 폴더가 없으면 만들어주세요.

  4. 우리는 자체서명 인증서를 생성하기때문에 다음단계에 걸쳐 인증서를 생성합니다.

    1단계. Generating an RSA private key

    실행할 명령어 : openssl genrsa -out server.key 1024

    D:\xampp\apache\bin>openssl genrsa -des3 -out server.key 1024
    Loading 'screen' into random state - done
    Generating RSA private key, 1024 bit long modulus
    ......++++++
    .........................++++++
    e is 65537 (0x10001)
    Enter pass phrase for server.key:
    Verifying - Enter pass phrase for server.key:

    Enter pass phrase for server.key: [4-10자리 비밀번호][엔터] 설정한 비밀번호는 다음 단계에서 초기화되니 아무거나 입력하셔도 됩니다.

    2단계. Generating a certificate sign request

    실행할 명령어 : openssl req -nodes -new -key server.key -out server.csr

    D:\xampp\apache\bin>openssl req -nodes -new -key server.key -out server.csr
    Loading 'screen' into random state - done
    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]:.
    State or Province Name (full name) [Some-State]:.
    Locality Name (eg, city) []:.
    Organization Name (eg, company) [Internet Widgits Pty Ltd]:localhost
    Organizational Unit Name (eg, section) []:.
    Common Name (e.g. server FQDN or YOUR name) []:localhost
    Email Address []:.
    
    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:mypassword
    An optional company name []:.

    ※ 위와 동일하게 추가 정보를 입력해주세요.

    3단계. Remove Passphrase from Key

    실행할 명령어 : copy server.key server.key.org

    D:\xampp\apache\bin>copy server.key server.key.org
    1 file(s) copied.

    실행할 명령어 : openssl rsa -in server.key.org -out server.key

    D:\xampp\apache\bin>openssl rsa -in server.key.org -out server.key
    Enter pass phrase for server.key.org:
    writing RSA key

    4단계. Generating a certificate

    실행할 명령어 : openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

    D:\xampp\apache\bin>openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
    Loading 'screen' into random state - done
    Signature ok
    subject=/O=localhost/CN=localhost
    Getting Private key

    ※ 만약 여기서 unable to write 'random state' 의 에러메시지가 나온다면 그것은 상단 2단계 변수설정을 빠뜨려서 그렇습니다.

    수정방법.Generating a self-signed certificate in one step

    실행할 명령어 : openssl req -nodes -new -x509 -keyout server.key -out server.crt

    D:\xampp\apache\bin>openssl req -nodes -new -x509 -keyout server.key -out server.crt
    Loading 'screen' into random state - done
    Generating a 1024 bit RSA private key
    ............++++++
    ............++++++
    writing new private key to 'server.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]:.
    State or Province Name (full name) [Some-State]:.
    Locality Name (eg, city) []:.
    Organization Name (eg, company) [Internet Widgits Pty Ltd]:localhost
    Organizational Unit Name (eg, section) []:.
    Common Name (e.g. server FQDN or YOUR name) []:localhost
    Email Address []:.

    5단계. Installing the certificate

    완성된 인증서 파일을 아파치에 복사해서 설치하도록 합니다.

    D:\xampp\apache\bin>copy /Y server.crt d:\Software\xampp\apache\conf\ssl.crt
            1 file(s) copied.
    
    D:\xampp\apache\bin>copy /Y server.key d:\Software\xampp\apache\conf\ssl.key
            1 file(s) copied.

  5. 인증서 생성이 완료되었습니다. 윈도우와 XAMPP 설정을 수정하도록 합니다.

    1단계. 내 도메인을 HOST 파일에 추가

    1. 수정할 파일 : C:\Windows\System32\drivers\etc\hosts

      127.0.0.1       mydomain

    ※ 메모장을 관리자권한으로 열어서 수정해주세요.

    2단계. Xampp 설정수정

    1. 수정할 파일 : D:\ xampp\apache\conf\httpd.conf

      ServerName *:80
      ServerName *:443
    1. 수정할 파일 : D:\ xampp\apache\conf\extra\httpd-vhosts.conf

      NameVirtualHost *:80
      NameVirtualHost *:443
      <VirtualHost *:80>
      DocumentRoot "D:\Home\mysite"
      ServerName mydomain
      <Directory "D:\Home\mysite">
      Options Indexes Includes execCGI
      AllowOverride All
      Require all granted
      </Directory>
      </VirtualHost>
      
      <VirtualHost *:443>
      DocumentRoot "D:\Home\mysite"
      ServerName mydomain
          SSLEngine on
          SSLCertificateFile conf/ssl.crt/server.crt
          SSLCertificateKeyFile conf/ssl.key/server.key
      <Directory "D:\Home\mysite">
      Options Indexes Includes execCGI
      AllowOverride All
      Require all granted
      </Directory>
      </VirtualHost>

      ※ 443포트와 가상호스트 설정을 추가합니다.


CloudFlare에서 SSL접속 설정하기

클라우드플레어는 CDN서비스가 적용되는 네임서버입니다. 더불어 무료계정에서도 SSL을 적용할수 있어서 아주 간편하게 SSL을 서비스를 적용해서 사용할수가 있네요.

※ 사이트주소 : www.cloudflare.com

  1. 대시보드

대시보드

  • SSL 상태를 현재 설정상태를 볼수가 있다. 기본설정은 Flexible 이다.

  1. Full로 변경하기 위해 상단메뉴 Crypto 를 선택합니다. SSL 적용상태를 확인합니다. 정상적용중이면 ACTIVE CERTIFICATE 로 녹색표시가 나옵니다. Full로 상태를 변경합니다.

SSL 항목설정

  • Off : ssl을 사용하지 않음
  • Flexible : 사용자와 CDN서버만 SSL을 적용합니다.
  • Full : 모든 과정에 SSL을 적용합니다.
  • Full(strict) : 사용자가 SSL을 지정하여 적용가능(유료회원용)

  1. 상단메뉴 Page Rles 를 선택합니다.

    ㅎㅎ

    • Create Page Rule 를 클릭합니다.

    tkwls

    • 첫번째 URL에 http://*mydomain.com/* 이라고 입력합니다.
    • 두번째 settings are 에 Always Use HTTPS 를 선택합니다. http로 들오는 트래픽까지 https로 전송하도록 하는겁니다. 저장하고 나오면 완료됩니다.

반응형

WRITTEN BY
페오마
집중~집중~집중!!!

,