본문 바로가기

Linux/Apache

Apache환경에서 SSL 사용하기 (https)




SSL 사용하기




제 블로그에서 Apache 설치를 보셨다면 (http://itgameworld.tistory.com/7)

Apache 설치 과정 중에 'enable-so --enable-ssl --enable-modules=ssl' 옵션을 주는 것을 확인할 수 있습니다.

SSL을 사용할 수 있도록 설정해준 것입니다.


ssl은 httpd-ssl.conf 에서 설정 가능합니다. 그런데 기본적으로 사용이 안되게 막혀져 있으니

httpd-ssl.conf 파일을 사용할 수 있도록 주석을 해제 해줍니다.


[root@localhost ~]# vi /usr/local/apache/conf/httpd.conf

...

Include conf/extra/httpd-ssl.conf

...

LoadModule ssl_module modules/mod_ssl.so

...


인증서 생성



인증키는 현재 경로에 생성되므로 인증키를 생성할 경로에서 다음 명령어를 실행합니다.

test 부분은 이름이니 자신이 원하는 이름으로 생성하시면 됩니다. (기본값은 server입니다)


[root@localhost ~]# openssl genrsa -des3 -out test.key 1024

...............++++++

............++++++

e is 65537 (0x10001)

Enter pass phrase for test.key: 비밀번호 입력

Verifying - Enter pass phrase for test.key: 한번 더 입력




[root@localhost ~]# ls

test.key





test.key를 이용하여 csr 생성




[root@localhost ~]# openssl req -new -key test.key -out test.csr

Enter pass phrase for test.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) [XX]: 

State or Province Name (full name) []:

Locality Name (eg, city) [Default City]:

Organization Name (eg, company) [Default Company Ltd]:

Organizational Unit Name (eg, section) []:

Common Name (eg, your name or your server's hostname) []:

Email Address []:


Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:

An optional company name []:



[root@localhost ~]# openssl x509 -req -days 365 -in test.csr -signkey test.key -out test.crt

[root@localhost ~]# ls

test.crt    test.csr    test.key


[root@localhost ~]# cp test.crt /usr/local/apache/conf/

[root@localhost ~]# cp test.key /usr/local/apache/conf/

[root@localhost ~]# vi /usr/local/apache/conf/extra/httpd-ssl.conf


...

SSLCertificateFile "/usr/local/apache/conf/test.crt"

#SSLCertificateFile "/usr/local/apache/conf/server-dsa.crt"

#SSLCertificateFile "/usr/local/apache/conf/server-ecc.crt"


...

SSLCertificateKeyFile "/usr/local/apache/conf/test.key"

#SSLCertificateKeyFile "/usr/local/apache/conf/server-dsa.key"

#SSLCertificateKeyFile "/usr/local/apache/conf/server-ecc.key"


...






접속




Apache를 재시작합니다.

같은 네트워크 상에 있는 장비에서 접속을 시도합니다.

https://IP 또는 도메인을 따로 지정해줬으면 도메인명

다음과 같은 경고가 뜨는 것은 인증서가 공공기관에서 나온 인증서가 아니기 때문에 뜨는 경고입니다.

우리가 생성했기 인증서이므로 무시해줍니다.


좌측 하단에 고급 - IP(안전하지 않음)(으)로 이동







정상적으로 접속이 잘 됩니다.








'Linux > Apache' 카테고리의 다른 글

Apache Tomcat의 로드밸런싱  (0) 2016.11.03
Apache 컴파일 설치  (0) 2016.08.05