본문 바로가기
컴퓨터 활용(한글, 오피스 등)/50_2.운영체제_리눅스

리눅스_웹/리눅스 서버에서의 TLS / SSL 버전 확인 및 설정

by 3604 2022. 11. 26.
728x90

ㅁ 방법1 =====================================

웹/리눅스 서버에서의 TLS / SSL 버전 확인 및 설정 방법 (SSL Labs)

 출처: https://iamfreeman.tistory.com/entry/%EC%84%9C%EB%B2%84%EC%97%90%EC%84%9C%EC%9D%98-TLS-SSL-%EB%B2%84%EC%A0%84-%ED%99%95%EC%9D%B8-%EB%B0%A9%EB%B2%95

요즘은 웹/리눅스 서버를 운영하면서
보안에 대한 인식이나 요구도가 높아지다 보니
각 프로토콜(Protocol)의 버전을 확인하고, 보안 프로토콜 등급을 올려주는 것이 좋습니다.
각 서버 운영 업체나 클라이언트들도 그렇게 요구를 하구요.

사실..이런 요구가 오기전에 미리미리 보안에 대한 중요성을 인식하고 대비하는 것이 더 좋겠죠.

TLS / SSL의 버전을 확인하는 방법은 크게 두가지로 구분됩니다.

  1. Openssl 명령어를 사용하는 방법
  2. Qualys SSL Labs. SSL Server Test

 

먼저,
Openssl 명령어를 이용해서 확인하는 방법을 알아봅니다.

[serviceWeb@web1 /etc/httpd/logs]
$ openssl
OpenSSL> s_client ?
unknown option ?
usage: s_client args

 -host host     - use -connect instead
 -port port     - use -connect instead
 -connect host:port - who to connect to (default is localhost:4433)
 -verify arg   - turn on peer certificate verification
 -cert arg     - certificate file to use, PEM format assumed
 -certform arg - certificate format (PEM or DER) PEM default
 -key arg      - Private key file to use, in cert file if
                 not specified but cert file is.
 -keyform arg  - key format (PEM or DER) PEM default
 -pass arg     - private key file pass phrase source
 -CApath arg   - PEM format directory of CA's
 -CAfile arg   - PEM format file of CA's
 -trusted_first - Use trusted CA's first when building the trust chain
 -reconnect    - Drop and re-make the connection with the same Session-ID
 -pause        - sleep(1) after each read(2) and write(2) system call
 -showcerts    - show all certificates in the chain
 -debug        - extra output
 -msg          - Show protocol messages
 -nbio_test    - more ssl protocol testing
 -state        - print the 'ssl' states
 -nbio         - Run with non-blocking IO
 -crlf         - convert LF from terminal into CRLF
 -quiet        - no s_client output
 -ign_eof      - ignore input eof (default when -quiet)
 -no_ign_eof   - don't ignore input eof
 -psk_identity arg - PSK identity
 -psk arg      - PSK in hex (without 0x)
 -ssl2         - just use SSLv2
 -ssl3         - just use SSLv3
 -tls1_2       - just use TLSv1.2
 -tls1_1       - just use TLSv1.1
 -tls1         - just use TLSv1
 -dtls1        - just use DTLSv1
 -fallback_scsv - send TLS_FALLBACK_SCSV
 -mtu          - set the link layer MTU
 -no_tls1_2/-no_tls1_1/-no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol
 -bugs         - Switch on all SSL implementation bug workarounds
 -serverpref   - Use server's cipher preferences (only SSLv2)
 -cipher       - preferred cipher to use, use the 'openssl ciphers'
                 command to see what is available
 -starttls prot - use the STARTTLS command before starting TLS
                 for those protocols that support it, where
                 'prot' defines which one to assume.  Currently,
                 only "smtp", "pop3", "imap", "ftp" and "xmpp"
                 are supported.
 -engine id    - Initialise and use the specified engine
 -rand file:file:...
 -sess_out arg - file to write SSL session to
 -sess_in arg  - file to read SSL session from
 -servername host  - Set TLS extension servername in ClientHello
 -tlsextdebug      - hex dump of all TLS extensions received
 -status           - request certificate status from server
 -no_ticket        - disable use of RFC4507bis session tickets
 -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)
 -legacy_renegotiation - enable use of legacy renegotiation (dangerous)
 -use_srtp profiles - Offer SRTP key management with a colon-separated profile list
 -keymatexport label   - Export keying material using label
 -keymatexportlen len  - Export len bytes of keying material (default 20)

자~~ 위에서 사용법을 보셨죠?
우리가 확인하고 싶은 것은 프로토콜의 버전이므로... 다음의 인자들을 기억하시면 됩니다.

 -ssl2         - just use SSLv2
 -ssl3         - just use SSLv3
 -tls1_2       - just use TLSv1.2
 -tls1_1       - just use TLSv1.1
 -tls1         - just use TLSv1
 -dtls1        - just use DTLSv1

 

이걸 토대로 사이트의 프로토콜 버전을 확인하는 명령어를 만들어서 실행해 볼까요?
naver.com에 대한 것을 확인해보면... 다음과 같은 식으로 하면 되겠죠?

### SSL3 확인 ###
[shell]$ openssl s_client -connect naver.com:443 -ssl3

### TLSv1.2 확인 ###
[shell]$ openssl s_client -connect naver.com:443 -tls1_2

### TLSv1 확인 ###
[shell]$ openssl s_client -connect naver.com:443 -tls1

### DTLSv1.1 확인 ###
[shell]$ openssl s_client -connect naver.com:443 -dtls1

 

사이트의 SSL3 버전 확인 방법

naver.com의 SSL3 프로토콜 버전 확인을 해볼까요?
해당 명령어를 실행해보면 다음과 같은 결과를 보실 수 있습니다.

[shell]$ openssl s_client -connect naver.com:443 -ssl3                  
CONNECTED(00000003)
140157034440520:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:s3_pkt.c:1256:SSL alert number 40
140157034440520:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:596:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 0 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : SSLv3
    Cipher    : 0000
    Session-ID: 
    Session-ID-ctx: 
    Master-Key: 
    Key-Arg   : None
    Krb5 Principal: None
    PSK identity: None
    PSK identity hint: None
    Start Time: 1658920386
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
---

 

사이트의 TLSv1.2 확인 방법

특정 사이트에 대한 TLSv1.2 확인 방법

[shell]# openssl s_client -connect domain.com:443 -tls1_2
CONNECTED(00000003)
depth=2 C = BE, O = GlobalSign nv-sa, OU = Root CA, CN = GlobalSign Root CA
verify return:1
depth=1 C = BE, O = GlobalSign nv-sa, CN = AlphaSSL CA - SHA256 - G2
verify return:1
depth=0 CN = *.domain.com
verify return:1
139714331289416:error:100AE081:elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group:ec_curve.c:316:
139714331289416:error:1408D010:SSL routines:SSL3_GET_KEY_EXCHANGE:EC lib:s3_clnt.c:1641:
---
Certificate chain
 0 s:/CN=*.domain.com
   i:/C=BE/O=GlobalSign nv-sa/CN=AlphaSSL CA - SHA256 - G2
 1 s:/C=BE/O=GlobalSign nv-sa/CN=AlphaSSL CA - SHA256 - G2
   i:/C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA
 2 s:/C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA
   i:/C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIGPjCCBSagAwIBAgIMLch7HY3T0eRMEOB/MA0GCSqGSIb3DQEBCwUAMEwxCzAJ
.
.
중략
.
.
EPo1erQuvjEP1DTHx2PGo4bD
-----END CERTIFICATE-----
subject=/CN=*.domain.com
issuer=/C=BE/O=GlobalSign nv-sa/CN=AlphaSSL CA - SHA256 - G2
---
No client certificate CA names sent
---
SSL handshake has read 4115 bytes and written 0 bytes
---
New, (NONE), Cipher is (NONE)
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : 0000
    Session-ID: 62E0EF9F76A0234350DE8BA9############8C959160F5084291260790
    Session-ID-ctx: 
    Master-Key: 
    Key-Arg   : None
    Krb5 Principal: None
    PSK identity: None
    PSK identity hint: None
    Start Time: 1658908575
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
---

 

위에서는 openssl 명령어를 통해서 확인하는 방법을 알아봤구요.
보다 손쉽게 웹사이트를 통해서 확인하는 방법도 있습니다.

Qualys SSL Labs. SSL Server Test

Qualys SSL Labs 사이트에 접속하셔서
확인하고자하는 웹사이트의 URL 주소만을 입력해주시면 됩니다.

접속하신 후 아래의 Hostname에 입력 하신 후 'Submit' 버튼을 누르시면 알아서 확인해줍니다.

https://www.ssllabs.com/ssltest/index.html

 

자~~
제 티스토리 ( https://iamfreeman.tistory.com )에 대해서 분석해볼까요?
여러가지 프로토콜에 대해서 테스팅합니다~

 

Summary

SSL Report의 결과를 요약해서 보여줍니다.

  • 사이트의 등급
  • 각 분야의 취득 점수
  • 해당 등급을 받게 된 이유

따끈한 결과 리포트가 나왔습니다.
이 모든게 공짜에요. 대박!!!
전체 등급을 보니 "B" 등급이네요.
왜 그런가보니... Protocol Support에서 점수를 많이 깍아 먹었어요.

 

왜 B등급을 받았는지를 아래의 표로 확인해볼까요?
2020년 1월 31일 이후부터는 TLSv1.0 or TLSv1.1을 제공할 경우 B 등급이래요.
자세한 내용은 아래 표를 참고하세요.

SSL Labs Grade Change for TLS 1.0 and TLS 1.1 Protocols

Update 1/31/2020: The grade change is now live on www.ssllabs.com. Servers that support TLS 1.0 or TLS 1.1 are capped to B grade.

 

Existing Grades Sample (기존 등급 샘플)

Server Configuration Grade
TLS 1.2, TLS 1.1, TLS 1.0 + HSTS + No Warning + TLS_FALLBACK_SCSV A+
TLS 1.2, TLS 1.1, TLS 1.0 + HSTS + No Warning +  No support for TLS_FALLBACK_SCSV A
TLS 1.2, TLS 1.1, TLS 1.0 + HSTS + Warnings + No support for TLS_FALLBACK_SCSV A-

 

Future Grades Sample (향후 등급 샘플)

Server Configuration Grade
TLS 1.2, TLS 1.1, TLS 1.0 + HSTS + No Warning + TLS_FALLBACK_SCSV B
TLS 1.2, TLS 1.1, TLS 1.0 + HSTS + No Warning +  No support for TLS_FALLBACK_SCSV B
TLS 1.2, TLS 1.1, TLS 1.0 + HSTS + Warnings + No support for TLS_FALLBACK_SCSV B
TLS 1.2 + HSTS + No Warning + TLS_FALLBACK_SCSV A+
TLS 1.2 + HSTS + No Warning + No support for TLS_FALLBACK_SCSV A
TLS 1.2 + HSTS + Warnings + No support for TLS_FALLBACK_SCSV A-

 

Certificate

SSL 인증서에 대한 정보를 보여줍니다.
사이트에 접속하면 주소창 왼쪽에 있는 자물쇠 모양을 클릭하시면 보이는 정보를 말합니다.

SSL 인증서 정보 확인

 

 

Additional Certificates
(if supplied)

만약에 제공된다면.... 추가적인 인증서의 정보들을 보여줍니다.

 

Certification Paths

 

Configuration

우리가 보려고했던 Protocols의 정보가 보이는군요.
아래의 정보를 통해 어떠한 Protocol이 사용중인지 알 수 있습니다.
다들 잘 아시겠지만. ^^
해당 프로토콜의 값이
Yes면 사용중인 것이고,
No면 미사용중인 겁니다.

 

Cipher Suites

암호화 스위트(Cipher Suite)는 전송 계층 보안(Transport Layer Security, TLS)에서 쓰이는 인터넷 보안 보조 알고리즘이다. 일반적으로 다음과 같은 구조를 가지고 있다.

TLS 1.0/TLS 1.1/TLS 1.2

TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

  • TLS - 프로토콜(SSL/TLS)
  • ECDHE - 키 교환방식
  • RSA - 인증서 검증(Authentication)
  • AES_128 - 대칭키를 이용한 블록 암호화 방식
  • GCM - 블록 암호 운용방식
  • SHA256 - 메시지 인증 (무결성)

TLS 1.3

TLS_AES_128_GCM_SHA256

 

 

Handshake Simulation

Handshake 에 대한 시뮬레이션 정보를 보여줍니다.

핸드셰이킹(handshaking), 주고받기는 정보기술과 전기통신 및 관련 분야에서 채널에 대한 정상적인 통신이 시작되기 전에 두 개의 실체 간에 확립된 통신 채널의 변수를 동적으로 설정하는 자동화된 협상 과정이다. 채널의 물리적인 확립이 잇따르며, 정상적인 정보 전송 이전에 이루어진다.

 

Protocol Details

Protocol의 상세 정보를 보여줍니다.
많이도 있네요.
근데.. 뭐 대부분이 No지?

 

HTTP Requests

HTTP 요청 정보들을 보여줍니다.

 

Miscellanceous

테스트 날짜와 경과시간 등의 정보를 보여줍니다.

 

SSL Report v2.1.10

 해당 Report를 만드는데 사용된 버전이 2.1.10이라는 군요.

 


사이트 접속 주소

Qualys SSL Labs. SSL Server Testhttps://www.ssllabs.com/ssltest/

 

SSL Server Test (Powered by Qualys SSL Labs)

SSL Server Test This free online service performs a deep analysis of the configuration of any SSL web server on the public Internet. Please note that the information you submit here is used only to provide you the service. We don't use the domain names or

www.ssllabs.com

 


브라우저 TLS 1.0, TLS 1.1 프로토콜 지원 중단

주요 브라우저별 TLS 1.0/1.1 통신 지원 중지 관련하여 브라우저사별 TLS 1.0/1.1 지원 중단 버전이 공지 되었습니다.
서버에서 TLS 프로토콜 설정을 하지 않으신 경우, 웹페이지 오류가 발생할 수 있으니 서버에서 TLS 프로토콜 설정을 반드시 진행하시기 바랍니다.

 

[브라우져별 TLS 1.0, TLS 1.1 중단 버전]

브라우저 TLS 종료 일정
Chrome Chrome 84.0.4147.89 (공식 빌드)
IE11
Edge
Microsoft Edge 84.0.522.40 (공식 빌드)
Microsoft 11 (2020년 9월 예정)
Safari 중단 예정 (공식 일정 미발표)
Firefox Firefox 78.0

 

[서버별 TLS 지원 버전]

웹서버 서버 조건
Apache Apache 2.2x 이상 / Openssl 1.0.1 이상
IIS Window Server 2008 R2 이상
Webtob 제조사 문의 필요
Tomcat Tomcat 7 이상 / Java 1.7 이상
OHS OHS 10.1.2.0.2 / Openssl 1.0.1 이상
IHS IHS 8.0 이상 / Openssl 1.0.1 이상
Nginx Openssl 1.0.1 이상
Iplanet Oracle iPlanet Web Server 7.0.21
lighttpd lighttpd 1.4.48 이상 / Openssl 1.0.1 이상
기타 서버 및 방화벽 제조사 문의

TLS 프로토콜 버전 설정 방법 (취약점 조치)

  • 취약한 프로토콜/설정
    - 결과적으로 TLSv1.2(서버에 따라 TLSv1.3 까지)만 사용하도록 설정해야 합니다.
    - 취약 설정은 보안 취약점이 발견될 때마다 추가/수정됩니다.
  • 취약 설정 : SSLv2, SSLv3, TLSv1, TLSv1.1
    - 취약 사유 1 : DROWN, POODLE 취약점으로 인해 차단 권장 (SSLv2, SSLv3)
    - 취약 사유 2 : 브라우저/OS 사의 요구로 인한 차단 권장 (TLSv1, TLSv1.1)
  • 권장 TLS Protocol 설정 기준
    - Mozilla 재단에서 제시한 “Intermediate compatibility” 설정 (2020.01.14 버전)
    - 참고 링크 : https://wiki.mozilla.org/Security/Server_Side_TLS
 

Security/Server Side TLS - MozillaWiki

Recommended configurations The Mozilla SSL Configuration Generator Mozilla maintains three recommended configurations for servers using TLS. Pick the correct configuration depending on your audience: Modern: Modern clients that support TLS 1.3, with no nee

wiki.mozilla.org


Apache 서버에 대한 TLSv, SSLv 설정 방법

설정 위치

SSL이 적용된 conf 파일의 VIrtualHost부분에 권장 설정 추가 or 수정

Apache httpd. (일반적인) 설정 경로

[spluspkg@SPAYPLUSAPP01 :/etc/httpd/conf.d]$ pwd
/etc/httpd/conf.d
[spluspkg@SPAYPLUSAPP01 :/etc/httpd/conf.d]$ ls -ltra
합계 40
-rw-r--r--. 1 root root   824 11월 15  2016 welcome.conf
-rw-r--r--. 1 root root  1252 11월 15  2016 userdir.conf
-rw-r--r--. 1 root root  2926 11월 15  2016 autoindex.conf
-rw-r--r--. 1 root root   366 11월 15  2016 README
-rw-r--r--. 1 root root   625  2월 18  2017 php.conf
drwxr-xr-x. 5 root root    86  3월 27  2017 ..
-rwx------. 1 root root    32  6월 10  2020 ssl_pass.sh
-rw-r--r--. 1 root root 10143  6월 10 18:38 ssl.conf
drwxr-xr-x. 2 root root  4096  6월 10 18:38 .
[spluspkg@SPAYPLUSAPP01 :/etc/httpd/conf.d]$

 

설정 방법

#   SSL Protocol support:
# List the enable protocol levels with which clients will be able to
# connect.  Disable SSLv2 access by default:
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1

#   SSL Cipher Suite:
#   List the ciphers that the client is permitted to negotiate.
#   See the mod_ssl documentation for a complete list.
SSLCipherSuite ALL:+HIGH:+MEDIUM:!SSLv2:!PSK:!SRP:!ADH:!AECDH:!EXP:!RC4:+SHA

 

Apache 서버에 대한 SSLv, TLSv 설정예

##
## SSL Virtual Host Context
##

<VirtualHost _default_:443>

# General setup for the virtual host, inherited from global configuration
DocumentRoot "/home/spluspkg/work/www"
ServerName blabla.com:443

# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn

#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on

#   SSL Protocol support:
# List the enable protocol levels with which clients will be able to
# connect.  Disable SSLv2 access by default:
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1

#   SSL Cipher Suite:
#   List the ciphers that the client is permitted to negotiate.
#   See the mod_ssl documentation for a complete list.
SSLCipherSuite ALL:+HIGH:+MEDIUM:!SSLv2:!PSK:!SRP:!ADH:!AECDH:!EXP:!RC4:+SHA

#   Speed-optimized SSL Cipher configuration:
#   If speed is your main concern (on busy HTTPS servers e.g.),
#   you might want to force clients to specific, performance
#   optimized ciphers. In this case, prepend those ciphers
#   to the SSLCipherSuite list, and enable SSLHonorCipherOrder.
#   Caveat: by giving precedence to RC4-SHA and AES128-SHA
#   (as in the example below), most connections will no longer
#   have perfect forward secrecy - if the server's key is
#   compromised, captures of past or future traffic must be
#   considered compromised, too.
#SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:MEDIUM:!aNULL:!MD5
#SSLHonorCipherOrder on 

#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
#SSLCertificateFile /home/spluspkg/cert/star_payncert_com_cert.pem
SSLCertificateFile /home/spluspkg/cert/20220610/File_Wildcard.payncert.com_crt.crt

#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
#SSLCertificateKeyFile /home/spluspkg/cert/star_payncert_com_key.pem
SSLCertificateKeyFile /home/spluspkg/cert/20220610/KeyFile_Wildcard.payncert.com_crt.key

#   Server Certificate Chain:
#   Point SSLCertificateChainFile at a file containing the
#   concatenation of PEM encoded CA certificates which form the
#   certificate chain for the server certificate. Alternatively
#   the referenced file can be the same as SSLCertificateFile
#   when the CA certificates are directly appended to the server
#   certificate for convinience.
#SSLCertificateChainFile /home/spluspkg/cert/Chain_RootCA_Bundle.crt
SSLCertificateChainFile /home/spluspkg/cert/20220610/ChainFile_ChainBundle.crt


#   Certificate Authority (CA):
#   Set the CA certificate verification path where to find CA
#   certificates for client authentication or alternatively one
#   huge file containing all of them (file must be PEM encoded)
#SSLCACertificateFile /home/spluspkg/cert/Chain_RootCA_Bundle.crt
SSLCACertificateFile /home/spluspkg/cert/20220610/CA_GLOBALSIGN_ROOT_CA.crt

JBoss Web 서버에 대한 TLSv, SSLv 설정 방법

설정 위치

사용자의 설치 위치마다 다르겠지만, 저의 경우에 설정파일 (standalone.xml)의 위치는 다음과 같습니다.

  • /jboss/domains/jboss_was11/configuration/standalone.xml
  • 다음의 설정 추가 : protocol="TLSv1.2"
protocol="TLSv1.2"

 

JBoss SSLv, TLSv 설정예

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" instance-id="${jboss.jvmRoute}" native="false">
	<configuration>
		<jsp-configuration x-powered-by="false"/>
	</configuration>
	<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
	<connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
	<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
	<ssl name="ssl" 
		 password="*****" 
		 certificate-key-file="${jboss.server.base.dir}/ssl/invusomuch_com.jks" 
		 sucipher-suite="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA"
		 protocol="TLSv1.2"/>
	</connector>
	<virtual-server name="default-host" enable-welcome-root="false">
		<alias name="localhost"/>
		<alias name="example.coacm"/>
		<access-log pattern="%a %t %H %p %U %s %T">
			<directory path="access"/>
		</access-log>
	</virtual-server>
</subsystem>

Oracle Http Server에 대한 TLSv 설정 방법

설정 위치

ssl.conf 파일의 SSL이 적용된 virtualhost부분에 TLSv에 대한 설정을 수정/추가 해주세요.

SSLProtocol all -TLSv1 -TLSv1.1

 

Oracle Http Server의 TLSv 설정예

<VirtualHost *:4463> #OHS_SSL_VH
	<IfModule ossl_module>
    	SSLEngine on
        
        SSLVerifyClient None
        SSLProtocol All -TLSv1 -TLSv1.1
        SSLCipherSuite	ECDHE-ECDSA-AES128-GCM-SHA256:BLABLABLABLABLABLABLABLABLABLABLABLABLABLA
        
        SSLCRLCheck Off
         #Path to the wallet
         SSLWallet "${ORACLE_INSTANCE}/config/fmwconfig/components/${COMPONENT_TYPE}/instances/${COMPONENT_NAME}/keystores/default"
         
         <FilesMatch "\.(cgi|shtml|phtml|php)$">
         	SSLOptions +StdEnvVars
         </FIlesMatch>
         ...

IBM Http Server에 대한 TLSv, SSLv 설정 방법

설정 위치

httpd.conf 파일의 SSL이 적용된 virtualhost부분에 TLSv, SSLv에 대한 설정을 수정/추가 해주세요.

SSLProtocolDisable SSLv2
SSLProtocolDisable SSLv3
SSLProtocolDisable TLSv10
SSLProtocolDisable TLSv11

 

IBM Http Server의 TLSv 설정예

<VirtualHost www.test.com:8443>
    SSLEnable
    ServerAdmin webmaster@kicassl.com
    DocumentRoot "C:Program Files (x86)/IBM/HTTPServer/htdocs/"
    ServerName www.test.com:8443
    SSLCipherSpec TLS_RSA_WITH_AES_256_CBC_SHA
    ErrorLog logs/ssl_error.log
    CustomLog logs/ssl_access.log combined
    
       
    SSLProtocolDisable SSLv2
    SSLProtocolDisable SSLv3
    SSLProtocolDisable TLSv10
    SSLProtocolDisable TLSv11
</VirtualHost>

Nginx (OpenSSL 1.0.1 이상) Server에 대한 TLSv 설정 방법

설정 위치

nginx.conf 파일의 SSL이 적용된 server 설정 부분에 TLSv에 대한 설정을 수정/추가 해주세요.

ssl_protocols TLSv1.2;

# NginX 버전이 1.17.0 이상인 경우
ssl_protocols TLSv1.2 TLSv1.3

 

Nginx Server TLSv 설정예

server {
	listen 443 ssl http2;
    listen [::]:443 ssl http2;
    
    ssl_certificate /path/to/signed_cert_plus_intermediates;
    ssl_certificate_key /path/to/private_key
    ssl_session_timeout 1d;
    ssl_session_cache shared:MoxSSL:10m;  # about 40000 sessions
    ssl_ssion_tickets off;
    
    ssl_dhparam /path/to/dhparam.pem;
    
    ssl_protocols TLSv1.2;

    # NginX 버전이 1.17.0 이상인 경우
    ssl_protocols TLSv1.2 TLSv1.3
    
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GC.......

참고 링크 : https://mozilla.github.io/server-side-tls/ssl-config-generator/

 

Redirecting to ssl-config.mozilla.org...

 

mozilla.github.io


IIS (Win 2008 R2 이상) Server에 대한 TLSv 설정 방법

설정 위치 : 레지스트리 2곳

  • (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\server)
  • (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\client)
DisabledByDefault [Value = 0]
Enabled [Value = 1]

위의 레지스트리 2곳에 키 값을 모두 생성해줍니다.

이후 나머지 폴더 (TLS 1.1, TLS 1.0 등)의 Ebanled 값은 0으로 수정하여 최종적으로  TLSv1.2만 사용하도록 설정합니다.


Tomcat (Java 1.7 이상) Server에 대한 TLSv 설정 방법

설정 위치

server.xml 파일의 SSL이 적용된 connector 설정 부분에 TLSv에 대한 설정을 수정/추가 해주세요.

sslEnabledProtocols="TLSv1.2"

 

Tomcat Server TLSv 설정예

<!-- Secure public HTTPS/SSL connector -->
<Connector port="8321" maxHttpHeaderSize="20480" URIEncoding="UTF-8" scheme="https" secure="true" SSLEnabled="true"
	clietnAuth="false" useServerCipherSuitesOrder="true" compression="on"
    compressableMimeType="text/html,text/xml,text/csv,text/css,text/javascript"
    keystoreFile="conf/.keystore"
    sslEnabledProtocols="TLSv1.2"
    ciphers="ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:!DES:!3DES:
    	!TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
        !TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
        !TLS_DHE_RSA_WITH_AES_128_GCM_SHA256:
        !TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
        RC4+RSA:+HIGH:+MEDIUM"
/>

Weblogic (Java 1.7 이상) Server에 대한 TLSv 설정 방법

설정 위치

설정 파일의 WebLogic 시작 매개 변수에 아래와 같이 TLSv에 대한 설정을 수정/추가 해주세요.

-Dweblogic.security.SSL.minimumProtocolVersion=TLSv1.2

WebtoB Server에 대한 TLSv 설정 방법

설정 위치

설정 파일의 WebtoB의 config 설정에 아래와 같이 TLSv에 대한 설정을 수정/추가 해주세요.

CertificateFile = "경로/키_인증서_병합한파일명.pem",
CertificateKeyFile = "경로/키_인증서_병합한파일명.pem"
Protocol = "-SSLv3 -TLSv1 -TLSv1.1",
RequiredCiphers = "ALL:!ADH:!EXPORT56:RC4+RSA:!SHA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL"

 

 

ㅁ 방법2 ==================================================================
 

Apache : CSR 생성 및 SSL 인증서 적용

출처: https://www.comodossl.co.kr/certificate/ssl-installation-guides/Apache-csr-crt.aspx

본 가이드는 인증서 파일 설정 시 참고 예제이며, 고객사 서버에 SSL 설치/적용 성공을 보증하지 않습니다.
설정 과정에서 발생하는 다양한 문제에 대한 해결은 보증 대상이 아닙니다. (인증서 자체 오류 시 무제한 재발급)
웹서버 자체 설정/작동 관련 사항은 웹서버 매뉴얼 또는 공급사 기술 지원을 이용하시기 바랍니다.

Apache 설치 방법 보기

Apache 웹서버에 SSL를 적용하기 위해 아래 두 항목이 웹서버에 설치되어 있어야 합니다.

  • Openssl 암호화 라이브러리
  • Mod_ssl 모듈

위 두 항목이 웹서버에 설치되어 있다면 개인키를 생성하고 생성된 개인키를 바탕으로 CSR 파일을 생성합니다.
생성된 CSR 파일을 한비로에 접수하여 정식 인증서를 발급받습니다.
발급된 인증서를 웹서버에 설치하게 되면 SSL 설정을 완료하게 됩니다.

위 일련의 진행사항은 아래와 같은 절차를 따르게 됩니다.

  1. openssl 라이브러리 설치 상태 확인
  2. mod_ssl 모듈 설치 상태 확인
  3. 개인키 생성
  4. CSR 생성
  5. 한비로에 접수
  6. 정식 인증서 발급
  7. SSL 설정
1. Openssl 라이브러리 설치 상태 확인

먼저 SSL를 설치하고자 하는 웹서버에 openssl 라이브러리 설치상태를 find 명령어를 활용하여 아래와 같이 확인합니다.


위와 같은 값을 보인다면 openssl 라이브러리 모듈은 rpm으로 설치된것입니다.
만약에 경로가 /usr/local 아래 있다면 모듈은 소스로 설치된 것입니다.
rpm으로 설치된 것이라면 rpm -qa 명령어를 사용하여 openssl-devel 설치여부도 함께 점검합니다.
버전에 따라 라이브러리 버전이 아래보이는 값과 차이가 있을수 있습니다.


Openssl 은 암호화 처리를 위한 독립 모듈로 최신 버전으로 설치하는 것을 권장합니다.

2. Mod-ssl Openssl 라이브러리 설치 상태 확인

Openssl과 마찬가지로 웹서버의 mod_ssl 설치 여부를 점검합니다.
Apache 웹서버는 두가지 방식으로 모듈 설치를 지원하고 있습니다. 정적과 동적인 방식으로 정적으로 설치된 경우는 아파치의 재설치까지 요구되며 동적인 경우는 손쉽게 모듈 설치가 가능합니다.
Apache가 /usr/local 아래 설치된 것을 기준으로 아래와 같은 방식으로 확인합니다.

정적으로 설치된 mod_ssl 모듈 확인
동적으로 설치된 mod_ssl 모듈 확인

웹서버에 설치된 모듈중 mod_so.c를 먼저 확인 후 동적으로 설치된 모듈중 mod_ssl.so를 확인합니다.
동적으로 설치된 경우 apache 설치 디렉토리의 module 이나 libexec 디렉토리내에 mod_ssl.so 의 존재여부를 확인합니다.

3. 개인키 생성

Openssl 명령어를 이용하여 웹서버의 RSA키( 2048비트 암호화 )를 생성합니다. ( sslhanbiro.key는 임의로 지정된 키값입니다. 원하는 이름으로 키를 생성합니다. )
패스워드를 지정하게 됩니다. 이때 입력된 패스워드는 차후 여러 차례 사용되므로 본인만이 알 수 있는 패스워드로 지정해 주시는 것이 좋습니다.


윈도우 아파치 이용하실 경우 '-des3' 구문은 제외하시기 바랍니다.
이때 생성되는 개인키는 반드시 백업을 받아놓고 사용하는 것이 좋습니다.

생성된 키는 아래와 같이 확인이 가능합니다. 패스워드를 확인하는데 이때는 키생성 시 입력한 패스워드를 입력합니다.
개인키 생성까지 완료되면 이제 CSR 생성을 하게됩니다.

4. 인증요청서( CSR ) 생성
발급이 완료된 인증서는 재발급 또는 변경이 불가하므로 CSR 생성 시 절대 주의 바랍니다.
CSR ( Certificate Signing Request ) 이란?

SSL 서버를 운영하는 회사의 정보를 암호화하여 인증 기관으로 보내 인증서를 발급받게 하는 일종의 신청서입니다.
CSR은 ASCII 텍스트 파일로 생성됩니다.
CSR을 생성할 때 서버의 식별명을 입력하게 됩니다. 식별명은 각 서버를 공유하게 나타내는 이름으로 다음과 같은 정보를 포함합니다.

  • Country Name ( 국가코드) [] : KR
  • State or Province Name ( 지역 ) [] : Seoul
  • Locality Name ( 시/군/구 ) [] : Seocho
  • Organization Name ( 회사명 ) [] : Hanbiro Inc
  • Organizational Unit Name ( 부서명 ) [] : Linux Team
  • Common Name ( 서비스도메인명 ) [] : www.hanbiro.com
  • Email Address [] : hanbiro@hanbiro.com
CSR 항목에 대한 설명
  • Country Name : 이것은 두 자로 된 ISO 형식의 국가 코드입니다.
  • State or Province Name : 시 이름을 입력해야 하며 약어를 사용할 수 없습니다.
  • Locality Name : 이 필드는 대부분의 경우 생략이 가능하며 업체가 위치한 곳를 나타냅니다.
  • Organization : 사업자 등록증에 있는 회사명과 일치되는 영문 회사명을 입력하시면 됩니다.
  • Organization Unit : "리눅스 관리팀", "윈도우 관리팀" 등과 같이 업체의 부서를 입력할 수 있습니다.
  • Common Name : 인증받을 도메인 주소를 입력하시면 됩니다.

이 정보로 웹 사이트를 식별하므로 호스트 이름을 변경할 경우 다른 디지털 ID를 요청해야 합니다.
호스트에 연결하는 클라이언트 브라우저가 디지털 ID의 이름과 URL이 일치하는지를 확인합니다.

CSR 항목 입력 시 주의사항
  • Common Name에는 인증서를 설치할 사이트의 도메인의 이름을 정확하게 입력하셔야 합니다.
  • Common Name에는 IP 주소, 포트 번호, 경로명, http:// 나 https:// 등은 포함할 수 없습니다.
  • CSR 항목에는 < > ~ ! @ # $ % ^ * / \ ( ) ? 등의 특수 68 문자를 넣을 수 없습니다.
  • CSR 생성 후 서버에 개인키 (Private Key)가 생성됩니다. 개인키를 삭제하거나 분실할 경우 인증서를 발급받아도 설치가 불가합니다. 따라서 꼭 개인키를 백업받아 두셔야 합니다.
  • 정보 입력 과정 마지막에 나오는 A challenge password 와 An optional company name 두 항목은 입력하지 마시고 Enter만 누르고 넘어가야 합니다. 두 정보가 입력될 경우 잘못된 CSR 생성될 수 있습니다.

위 주의사항을 유의하여 아래와 같은 절차로 CSR 생성을 진행합니다.

* 윈도우+아파치의 경우 -config "openssl.cnf 절대 경로"를 입력 하시기 바랍니다.
생성된 CSR 정보는 아래처럼 확인이 가능합니다.
5. 한비로에 접수
6. 정식 인증서 발급생성된 CSR 을 출력하면 아래와 같은 base64 형식의 문서를 볼 수 있습니다.

이 문서의 첫 줄 -----BEGIN …부터 마지막 줄 -----END …까지 복사하여 지정된 SSL 접수 페이지에 복사하여 붙여넣은 뒤 입력 정보와 함께 전송하면 접수가 완료됩니다.

7. 인증서 설치

접수한 CSR 파일이 정상적으로 생성되었다면 별다른 문제없이 인증서를 발급 받을 수 있습니다.
인증서 파일은 신청 시 기록한 Email 주소를 통해 인증서를 첨부파일로 수신하게 됩니다.

  1.  인증서 서버에 복사도메인.crt와 Chain 폴더를 보실 수 있습니다.
    여기에서 필요한 파일은 도메인.crt 와 Chain 폴더 안에 있는 AAACertificateServices.crt, rsa-dv.chain-bundle.pem 이 두 파일 입니다.
  2.  웹서버 환경설정아파치가 설치된 디렉토리로 이동하여 conf 디렉토리 내의 httpd.conf 파일의 복사본을 만들어 둡니다.
    웹서버 설정의 기본이 되는 파일로 만일의 경우를 대비하여 백업본을 유지하는 것이 좋습니다.
    백업이 완료되면 vi 편집기를 이용하여 httpd.conf 내용 중 아래 사항을 설정하신 정보에 맞게 수정합니다.httpd.conf 예문
    1. <VirtualHost 127.0.0.1:443> 127.0.0.1를 사용하는 장비의 아이피로 변경
       - 443 : SSL 통신 포트 번호입니다. 일반적으로 웹서버는 80 포트를 사용합니다.
    2. SSLEngine 스위치 off를 on으로 변경해 줍니다.
    3. SSLCertificateFile / SSLCertificateKeyFile에는 인증서의 설치 경로와 개인키 파일의 경로를 적어 줍니다.
  3.  root 인증서 경로 설정SSLCACertificateFile 에는 root 인증서 위치를 알려주는 것으로 유저의 브라우저에 신뢰받는 CA리스트가 없을 경우를 위해 경로를 반드시 지정해 주어야 합니다.
  4.  웹서버 재실행
    • 설정 파일의 정상적인 수정 여부를 점검하기 위한 체크 ./httpd -t
    • 수정된 사항의 적용을 위해 아파치 데몬 정지 ./apachectl stop
    • 아파치 데몬 활성화 ./apachectl startssl ( 아파치 데몬 활성화는 ./apachectl start로 가능합니다. 여기에 ssl을 붙여줌으로써 ssl을 사용하게 됩니다. )
    초기 개인키 생성 시 입력했던 패스워드를 기억하시고 계실겁니다. SSL 실행을 위해 패스워드를 물어보는데 이때 개인키 생성 시 입력했던 패스워드를 입력하시면 SSL 웹데몬이 활성화 됩니다.
  5.  웹서버 포트 점검아래와 같이 활성화된 데몬의 포트를 점검해 봅니다.
  6.  웹서비스 동작 상태 점검인터넷 주소창에 https://사용 도메인 입력 후 해당 페이지의 정상적인 동작 여부를 점검합니다.
    SSL 설정한 사이트에 대한 정상적인 서비스 상태 점검

    페이지 하단을 보시면 열쇠 아이콘이 보이게 됩니다. 아이콘을 클릭하게 되면 위와 같이 인증서 정보를 확인하실 수 있습니다.

 

방법3 ===============================================

[Apache] SSL 적용하기 / HTTP->HTTPS로 Rewrite하기

출처: https://waspro.tistory.com/383

 포스팅은 Apache에서 SSL을 적용하는 가이드입니다.


기존 설치되어있는 Apache에서 SSL 인증서를 만들고, 적용하여 HTTP>HTTPS로의 Rewrite를 테스트해보도록 하겠습니다. 

Apache 웹서버에 SSL를 적용하기 위해 아래 두 항목이 웹서버에 설치되어 있어야 합니다.

- Openssl 암호화 라이브러리 
- Mod_ssl 모듈 
 
위 두 항목이 웹서버에 설치되어 있다면 개인키를 생성하고 생성된 개인키를 바탕으로 CSR 파일을 생성합니다. 
생성된 CSR 파일을 공식 인증기관에 접수하여 정식 인증서를 발급받습니다.
발급된 인증서를 웹서버에 설치하게 되면 SSL 설정을 완료하게 됩니다.
위 일련의 진행사항은 아래와 같은 절차를 따르게 됩니다. 
1. openssl 라이브러리 설치상태 확인 
2. mod_ssl 모듈 설치상태 확인 
3. 개인키 생성 
4. CSR 생성 
5. 공식 인증기관에 접수 
6. 정식 인증서 발급 
7. SSL 설정
그럼 진행하도록 하겠습니다. 
 
1. openssl 설치
 
-bash-4.2$ sudo yum install openssl
[sudo] password for apacheUser:
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.cdnetworks.com
 * extras: centos.mirror.cdnetworks.com
 * updates: centos.mirror.cdnetworks.com
Package 1:openssl-1.0.2k-12.el7.x86_64 already installed and latest version
 

 

2. mod_ssl 을 설치합니다. 

-bash-4.2$ sudo yum install mod_ssl
[sudo] password for apacheUser:
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.cdnetworks.com
 * extras: centos.mirror.cdnetworks.com
 * updates: centos.mirror.cdnetworks.com
..
..
Total download size: 111 k
Installed size: 224 k
Is this ok [y/d/N]: y
Downloading packages:
mod_ssl-2.4.6-80.el7.centos.1.x86_64.rpm                                                                                                                         | 111 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:mod_ssl-2.4.6-80.el7.centos.1.x86_64                                                                                                                               1/1
  Verifying  : 1:mod_ssl-2.4.6-80.el7.centos.1.x86_64                                                                                                                               1/1


Installed:
  mod_ssl.x86_64 1:2.4.6-80.el7.centos.1


Complete!
 

 

/etc/httpd/modules 아래에 mod_ssl.so 이 생성됩니다. 

이를 APACHE_HOME/modules/아래에 copy합니다. 

 

2.openssl 명령어를 이용해서, 개인키 생성 > CSR 생성 > 자체적으로 서명한 crt파일 생성을 완료합니다. 

 

개인키 생성>
-bash-4.2$ sudo openssl genrsa -des3 -out test.key 2048
[sudo] password for apacheUser:
Generating RSA private key, 2048 bit long modulus
..................................+++
.............................................................................................+++
e is 65537 (0x10001)
Enter pass phrase for test.key:
Verifying - Enter pass phrase for test.key:
 
 
CSR 생성>
-bash-4.2$ sudo 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]:kr
State or Province Name (full name) []:kyungkido
Locality Name (eg, city) [Default City]:bundanggu
Organization Name (eg, company) [Default Company Ltd]:sw
Organizational Unit Name (eg, section) []:kkm
Common Name (eg, your name or your server's hostname) []:kkm
Email Address []:kkm


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


자체적으로 서명한 crt파일 생성>
-bash-4.2$ sudo openssl x509 -req -days 365 -in test.csr -signkey test.key -out test.crt
Signature ok
subject=/C=kr/ST=kyungkido/L=bundanggu/O=sw/OU=kkm/CN=kkm/emailAddress=kkm
Getting Private key
Enter pass phrase for test.key:

 

How To Generate SSL Key, CSR and Self Signed Certificate For Apache 

https://www.thegeekstuff.com/2009/07/linux-apache-mod-ssl-generate-key-csr-crt-file/

 

3. httpd.conf 수정

 

LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
→ mod_ssl과 mod_socache_shmcb 모듈을 활성화합니다.


Include conf/extra/httpd-ssl.conf
→ httpd-ssl.conf를 사용할 수 있도록 활성화 시킵니다.


LoadModule rewrite_module modules/mod_rewrite.so
 rewrite 기능을 사용할 수 있도록 활성화 시킵니다.

 

4. httpd-ssl.conf 설정

 

<VirtualHost _default_:443>


#   General setup for the virtual host
DocumentRoot "/home/apache/apache/htdocs"
ServerName www.kkm.com:443
ServerAdmin you@example.com
ErrorLog "/home/apache/apache/logs/error_log"
TransferLog "/home/apache/apache/logs/access_log"
JkMount /* load_balancer
     
SSLEngine on
SSLCertificateFile [인증서 파일 경로]
SSLCertificateKeyFile [키파일 경로]
SSLCACertificateFile [중계인증서 파일경로] 

 

5. httpd-vhost.conf 설정 : HTTP > HTTPS 로의 Rewrite를 위한 설정을 합니다. 

<VirtualHost *:80>
    DocumentRoot "/home/apache/apache/htdocs"
    ServerName www.kkm.com
    ServerAlias www.kkm.com
    ErrorLog "/home/apache/apache/logs/ddd/error_log"
    CustomLog "/home/apache/apache/logs/ddd/access_log" common
    JkMount /* load_balancer
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule .* https://www.kkm.com/session.jsp
</VirtualHost>

*참고하기*

RewriteCond %{HTTPS} on/off 설정을 이용하여 프로토콜 별로 처리할 수 있습니다.
Rewrite를 추가하는 부분에서 SSL 인증서를 사용하고 있다면
[P] 옵션을 사용하기 때문에  (P=Proxy)
SSLProxyEngine On 
설정을 추가해줘야 합니다.
 
Proxy를 사용하지 않아도 될 경우에는 [P,R,L] -> [R=301,L] 사용
 
- HTTP를 HTTPS로 리다이렉트
   <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [P,R,L]
   </IfModule>
 
- HTTPS를 HTTP로 리다이렉트
   SSLProxyEngine On    => SSL 인증서를 이용하고 있다면 넣어줘야 한다.
   <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTPS} on
        RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [P,R,L]
   </IfModule>
 
- HTTP/HTTPS를 고려하여, 받은 URL 그대로 리다이렉트.
 
   SSLProxyEngine On    => SSL 인증서를 이용하고 있다면 넣어줘야 한다.   
<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTPS} on
        RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [P,R,L]
        RewriteCond %{HTTPS} off
        RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [P,R,L]
   </IfModule> 

 

*참고하기*

한 컴퓨터/장비에서 여러개의 웹서비스들을 구동할 수 있도록 할 수 있는 방법을 
아파치 가상 호스트(VirtualHost)라고 하며,그 적용방법은 크게 아래의 4가지로 나눌 수 있습니다.


1. IP기반 가상호스트(IP-based virtual host) : 가상호스트별로 각각 IP주소 1개씩 부여
2. 포트기반 가상호스트(port-based virtual host) : 동일한 호스트에 포트만 다르게 지정
3. 이름기반 가상호스트(name-based virtual host) : 같은 IP에서 도메인명이 다른 가상호스트들 운용
4. 기본 가상호스트(default virtual host) : 특정 호스트에 해당 사항 없을때 기본적으로 응답하게 될 호스트

일반적인 설정은 보통 httpd-vhosts.conf에 가상 호스트를 설정하고, httpd.conf 파일 마지막에 Include conf/extra/httpd-vhosts.conf를 추가하는 방식으로 이루어집니다.
IP 기반 가상 호스트(IP-based virtual host)
- IDC 또는 전용망 네트워크환경에서 한 1개의 서버장비에 여러개의 IP를 할당받고 IP별로 가상호스트를 사용하는 방법입니다.
- IP추가를 위해 각각의 네트워크 설정 등이 필요합니다.

 
Listen 211.49.89.1:80
 isten 211.49.89.2:80

 <VirtualHost 211.49.89.1:80>
   DocumentRoot /var/www/site1
   ServerName site1.example.com
 </VirtualHost>

 <VirtualHost 211.49.89.2:80>
   DocumentRoot /var/www/site2
   ServerName site2.example.com
 </VirtualHost>
 

포트 기반 가상 호스트(port-based virtual host)
- 포트를 기반으로 가상 호스트를 설정합니다. Listen 포트에 사용할 포트를 여러개 설정한 후 VirtualHost를 해당 포트로 설정하면 됩니다.
- 포트번호를 사용자가 미리알고 사용하여야하는 용도의 서비스에 적합하며, 1개의 장비/회선/IP에 각기 다른 여러개의 포트로 구분하여 사용하는 서비스에 적합합니다.
 
 
Listen 80
 Listen 90

 <VirtualHost 211.49.89.1:80>
   DocumentRoot /var/www/port_80
  ServerName site1.example.com
 </VirtualHost>

 <VirtualHost 211.49.89.1:90>
   DocumentRoot /var/www/port_90
  ServerName site2.example.com
 </VirtualHost>
 

이름 기반 가상 호스트(name-based virtual host)
- 한 장비/IP에 여러개의 도메인 이름을 부여하고 도메인 이름별로 가상 호스트를 사용하는 방법입니다.
- 일반적인 웹호스팅 서비스에 많이 사용되는 방식으로 이름 기반 가상 호스트는 클라이언트 요청시 전송하는 헤더중 Host 헤더정보를 사용하여 가상 호스트 설정에 따라 웹 서비스를 하게 됩니다.
 
  
NameVirtualHost *:80

 <VirtualHost *:80>
  DocumentRoot /var/www/site1
  ServerName id1.codns.com
</VirtualHost>

 <VirtualHost *:80>
  DocumentRoot /var/www/site2
  ServerName id2.codns.com
</VirtualHost>
 
 
기본 가상호스트(default virtual host)
- 기본 가상호스트란 어떤 가상호스트에도 해당하지않은 IP 주소와 포트에 대한 모든 요청을 처리하여 호스트를 띄워주는 것입니다.즉, 지정된 가상호스트가 없을 때 기본적으로 응답에 응할 호스트를 지정해 둔 것이 기본 가상호스트입니다.
- default(기본) 가상호스트의 포트로 와일드카드를 사용하여 어떤 요청도 주서버로 못가도록 만듭니다.
- AliasMatch나 RewriteRule을 사용하여 어떤 요청을 특정 페이지(혹은 스크립트)로 재작성할(rewrite) 수 있습니다.

 
NameVirtualHost *:80

 <VirtualHost _default_:*>
  DocumentRoot /var/www/site
  DocumentRoot /www/default
 </VirtualHost>
 
 
예제에 표기된 항목설명
1. NameVirtualHost 항목 : 만일 서버가 유동아이피를 사용하신다면 "NameVirtualHost *"과 같이 *를 아이피대신 사용하세요. 원래는 "NameVirtualHost 아이피"와 같이 현재 서버의 아이피를 넣어줘야 하지만 유동아이피를 사용하므로 아이피가 바뀔때 마다 이 부분을 수정해 줄 수는 없는 일입니다. "*" 기호는 "모든"이라는 의미를 가지고 있으므로 아이피대신 이 기호를 사용하시면 됩니다.
2. VirtualHost 항목 : 이 부분도 위와 같은 이유로 "*"를 사용하시면 됩니다.
3. ServerName 항목 : 사용할 도메인 주소를 적어 줍니다.
4. ServerAlias 항목 : 이것은 어떤 도메인으로 접속했을 때 홈페이지를 보이도록 할 것인지를 정하는 부분입니다. 즉, 첫번째 가상 호스트에서는 "*.aaa.com"을 지정했으므로 "aaa.com"을 포함한 "xxx.aaa.com" , "yyy.aaa.com" 등 앞에 어떠한 레코드(서브 도메인)를 붙여서 접속하더라도 모두 홈페이지를 보여줍니다.  이와는 다르게 두번째 가상 호스트에서는 "*"기호를 사용하지 않았으므로 이 항목에서 지정한 "bbb.com" , "xxx.bbb.com" , "www.bbb.com"로 접속 했을 때만 홈페이지를 보여줍니다.
5. DocumentRoot 항목 : 각각의 가상 호스트가 갖게될 홈디렉토리의 경로를 적어 줍니다. 윈도우용 아파치의 경우는 "C:\Apache2.2\htdocs\site"형식으로 경로를 작성하며, 리눅스의 경우에는 "/var/www/site"형식으로 작성하시면 됩니다. 

6.모든 설정 완료 후, apache를 기동합니다. 

 

7.결과 

http://www.kkm.com/session.jsp 호출 시,

https://www.kkm.com/session.jsp 로 호출되는것을 확인할 수 있습니다. 

 

 

 

 

 

방법4  ========================================================

 CentOS7 Apache ssl 인증서 적용 그리고 80 to 443 redirect

 출처: https://cleanupthedesk.tistory.com/27

HOWTO 2020. 6. 5. 08:35

ssl 인증서를 적용하는 일이 자주 있는 건 아니라서 

매번 할 때는 어케어케 찾아서 하는데 매번 헤맨다 ㅠㅠ 그래서 오늘은 정리!

 

1.mod_ssl 설치

# yum install mod_ssl -y

2. httpd.conf 에 Load Modle 추가 

1) LoadModule, Include 부분 중에 없는 항목 추가

2) ServerName 도메인으로 추가

# vi /etc/httpd/conf/httpd.conf

LoadModule ssl_module modules/mod_ssl.so
Include conf.modules.d/.conf
Include conf.d/.conf

ServerName XXX.YYY.com

4. ssl.conf 파일 수정 

httpd.conf 에 모든 내용을 담으면 헷갈려서 ssl.conf 에 인증서 정보 설정

# vi /etc/httpd/conf.d/ssl.conf

LoadModule ssl_module modules/mod_ssl.so
Include conf.modules.d/.conf
Include conf.d/.conf


LoadModule ssl_module modules/mod_ssl.so
NameVirtualHost *:443
Listen 443


AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl
###################################
## SSL Virtual Host Context
################################
<VirtualHost *:443>


ServerAdmin $mail_ID@naver.com  -> 수정
ServerName XXX.YYY.com -> 수정


DocumentRoot /var/www/html
ErrorLog    /var/log/httpd/ssl-test.or.kr-error_log
TransferLog /var/log/httpd/ssl-test.or.kr_access_log


LogLevel error
SSLEngine on
SSLProtocol all -SSLv2


SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW

-> 아래 부분 키 저장 경로에 맞게 수정

SSLCertificateFile /root/keys/cert.pem 
SSLCertificateKeyFile /root/keys/keys.pem
SSLCertificateChainFile /root/keys/chain.pem


</VirtualHost> 

 

5. apache httpd 재기동

# systemctl restart httpd

 

6. 브라우저에서 설정한 도메인으로 https 접근되는지 확인 

 

7. ssl 인증서 적용까지만 하면 https 로 접근했을때만 보안 연결이 되므로 http (80)로 접근하더라도 https(443) 로 redirect 시켜주는게 좋은데, 이때는 httpd.conf 에만 VirtualHost 설정을 추가하면 된다.

httpd.conf 파일 제일 하단에 아래 내용을 추가해줬다.

# vi /etc/httpd/conf/httpd.conf

<VirtualHost :80>
Servername     XXX.YYY.com -> 수정
<IfModule mod_rewrite.c> 
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^/user/login(.)$ https://%{HTTP_HOST}%{REQUEST_URI} [R, L]
</IfModule> 
</VirtualHost> 

 

8. apache httpd 재기동

# systemctl restart httpd

 

9. 브라우저에서 설정한 도메인으로 http 연결을 하면 https 로 자동 변환되어 보안 연결이 사용되었다는 자물쇠를 확인할 수 있다. 

 



설치전 필요한 인증서 파일들
개인키파일 / 개인인증파일 / 외부root인증파일


설치전 필요한 설정
httpd.conf에서
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Include conf/extra/httpd-ssl.conf
 
주석제거


vi로 httpd-ssl.conf 파일 수정


SSL포트 지정한다. 기본(443)외에 사용할 포트가 있다면 여기서 수정해주면 된다.
Listen 443


crt, crl 파일을 인식하게끔 추가한다.
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl




SSL시작시 패스워드를 자동으로 인식하게끔 쉘프로그램 등록
SSLPassPhraseDialog exec:쉘파일경로




[쉘파일 내용]
#!/bin/sh
echo 패스워드
*퍼미션은 700




가상호스트 설정
<VirtualHost 가상호스트네임:SSL포트번호>
ServerName SSL신청시 입력했던 도메인
 
SSLCertificateFile 개인인증파일 경로
SSLCertificateKeyFile 개인키파일 경로
SSLCACertificateFile 외부root파일 경로




httpd -t로 구문검사후 실행
728x90