curl 통신시 tls 1.0 ~ tls 1.3 버전까지 다양하게 통신을 테스트하는데
현재는 tls 1.0 tls 1.1 버전은 사용안하는게 좋아서 거의 통신을 안하지만 기본적인 curl 으로 tls 체크를 진행할때
현재 사용하는 curl 의 지원되는 최신으로 통신이 기본으로 구성이 된다
현재 서버의 curl 버전 7.6
1 2 3 4 5 |
[root@localhost ~]# curl -V curl 7.61.1 (x86_64-redhat-linux-gnu) libcurl/7.61.1 OpenSSL/1.1.1k zlib/1.2.11 brotli/1.0.6 libidn2/2.2.0 libpsl/0.20.2 (+libidn2/2.2.0) libssh/0.9.6/openssl/zlib nghttp2/1.33.0 Release-Date: 2018-09-05 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz brotli TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL |
CURL 7.6 버전에서 tls 1.2로 통신을 테스트 진행해보면
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
[root@localhost ~]# curl --tlsv1.2 -I -v -L https://nginxtest.xinet.kr| more * Rebuilt URL to: https://nginxtest.xinet.kr/ % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 112.175.245.208... * TCP_NODELAY set * Connected to nginxtest.xinet.kr (112.175.245.208) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none } [5 bytes data] * TLSv1.3 (OUT), TLS handshake, Client hello (1): } [512 bytes data] * TLSv1.3 (IN), TLS handshake, Server hello (2): { [122 bytes data] * TLSv1.3 (IN), TLS handshake, [no content] (0): { [1 bytes data] * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8): { [19 bytes data] * TLSv1.3 (IN), TLS handshake, [no content] (0): { [1 bytes data] * TLSv1.3 (IN), TLS handshake, Certificate (11): { [3690 bytes data] * TLSv1.3 (IN), TLS handshake, [no content] (0): { [1 bytes data] * TLSv1.3 (IN), TLS handshake, CERT verify (15): { [264 bytes data] * TLSv1.3 (IN), TLS handshake, [no content] (0): { [1 bytes data] * TLSv1.3 (IN), TLS handshake, Finished (20): { [52 bytes data] * TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1): } [1 bytes data] * TLSv1.3 (OUT), TLS handshake, [no content] (0): } [1 bytes data] * TLSv1.3 (OUT), TLS handshake, Finished (20): } [52 bytes data] * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=nginxtest.xinet.kr * start date: Sep 20 05:57:18 2023 GMT * expire date: Oct 21 05:57:17 2024 GMT * subjectAltName: host "nginxtest.xinet.kr" matched cert's "nginxtest.xinet.kr" * issuer: C=BE; O=GlobalSign nv-sa; CN=AlphaSSL CA - SHA256 - G4 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 } [5 bytes data] * TLSv1.3 (OUT), TLS app data, [no content] (0): } [1 bytes data] * TLSv1.3 (OUT), TLS app data, [no content] (0): } [1 bytes data] * TLSv1.3 (OUT), TLS app data, [no content] (0): } [1 bytes data] * Using Stream ID: 1 (easy handle 0x55b1477b35e0) } [5 bytes data] * TLSv1.3 (OUT), TLS app data, [no content] (0): } [1 bytes data] > HEAD / HTTP/2 > Host: nginxtest.xinet.kr > User-Agent: curl/7.61.1 > Accept: */* > { [5 bytes data] * TLSv1.3 (IN), TLS handshake, [no content] (0): { [1 bytes data] * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): { [265 bytes data] * TLSv1.3 (IN), TLS handshake, [no content] (0): { [1 bytes data] * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): { [265 bytes data] * TLSv1.3 (IN), TLS app data, [no content] (0): { [1 bytes data] * Connection state changed (MAX_CONCURRENT_STREAMS == 128)! } [5 bytes data] * TLSv1.3 (OUT), TLS app data, [no content] (0): } [1 bytes data] * TLSv1.3 (IN), TLS app data, [no content] (0): { [1 bytes data] < HTTP/2 200 < server: nginx/1.21.6 < date: Wed, 20 Sep 2023 07:50:52 GMT < content-type: text/html; charset=UTF-8 < x-powered-by: PHP/8.1.2 < 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 * Connection #0 to host nginxtest.xinet.kr left intact HTTP/2 200 server: nginx/1.21.6 date: Wed, 20 Sep 2023 07:50:52 GMT content-type: text/html; charset=UTF-8 x-powered-by: PHP/8.1.2 |
위와 같이 tls 1.3 버전으로 상위 버전을 지원하면 바로 상위버전으로 통신을 진행한다
실제 서버의 로그 상태를 봐도 tls 1.3 을 사용한것을 확인 할 수 있다
그럼 나는 tls 1.2 버전으로 강제적으로 한번 curl 테스트를 하려면 옵션을 지정하면 된다 –tls-max 1.2 옵션을 주고 tls 1.2로 통신 테스트
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
[root@localhost ~]# curl --tlsv1.2 --tls-max 1.2 -I -v -L https://nginxtest.xinet.kr| more * Rebuilt URL to: https://nginxtest.xinet.kr/ % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 112.175.245.208... * TCP_NODELAY set 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to nginxtest.xinet.kr (112.175.245.208) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none } [5 bytes data] * TLSv1.2 (OUT), TLS handshake, Client hello (1): } [232 bytes data] * TLSv1.2 (IN), TLS handshake, Server hello (2): { [106 bytes data] * TLSv1.2 (IN), TLS handshake, Certificate (11): { [3683 bytes data] * TLSv1.2 (IN), TLS handshake, Server key exchange (12): { [300 bytes data] * TLSv1.2 (IN), TLS handshake, Server finished (14): { [4 bytes data] * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): } [37 bytes data] * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): } [1 bytes data] * TLSv1.2 (OUT), TLS handshake, Finished (20): } [16 bytes data] * TLSv1.2 (IN), TLS handshake, Finished (20): { [16 bytes data] * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=nginxtest.xinet.kr * start date: Sep 20 05:57:18 2023 GMT * expire date: Oct 21 05:57:17 2024 GMT * subjectAltName: host "nginxtest.xinet.kr" matched cert's "nginxtest.xinet.kr" * issuer: C=BE; O=GlobalSign nv-sa; CN=AlphaSSL CA - SHA256 - G4 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 } [5 bytes data] * Using Stream ID: 1 (easy handle 0x55adec3e55e0) } [5 bytes data] > HEAD / HTTP/2 > Host: nginxtest.xinet.kr > User-Agent: curl/7.61.1 > Accept: */* > { [5 bytes data] * Connection state changed (MAX_CONCURRENT_STREAMS == 128)! } [5 bytes data] < HTTP/2 200 < server: nginx/1.21.6 < date: Wed, 20 Sep 2023 07:56:04 GMT < content-type: text/html; charset=UTF-8 < x-powered-by: PHP/8.1.2 |
강제 옵션을 지정하면 tls 1.2 버전으로 통신이 되는 것을 확인 할 수 있다
서버상의 로그도 확인 해보자 / 로그에서는 tls 1.2 버전을 확인 할 수 있다
이렇게 curl tls 통신을 테스트 할때 버전을 지정해서 사용하면 된다
1 2 3 4 5 6 7 8 9 10 11 12 |
### 버전 1.2 --tlsv1.2 ### 버전 1.3 --tlsv1.3 ### 버전 1.1 --tlsv1.1 ### v2, v3 버전시 --sslv2 --sslv3 |
sslv3 으로 통신 테스트를 하면 서버상에서 지원 ( 인증서가 설치된 web server)을 하지 않기 때문에 통신이 되지 않는다
1 2 3 4 5 6 7 8 9 |
[root@localhost ~]# curl --sslv3 -I -v -L https://nginxtest.xinet.kr| more * Rebuilt URL to: https://nginxtest.xinet.kr/ % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 112.175.245.208... * TCP_NODELAY set * Connected to nginxtest.xinet.kr (112.175.245.208) port 443 (#0) * OpenSSL was built without SSLv3 support curl: (4) OpenSSL was built without SSLv3 support |
curl 버전이 낮은 7.29 버전에서 동일하게 테스트를 진행
1 2 3 4 |
[root@localhost ~]# curl -V curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.53.1 zlib/1.2.7 libidn/1.28 libssh2/1.8.0 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets |
tls 1.2 버전으로 테스트
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
[root@localhost ~]# curl --tlsv1.2 -I -v -L https://nginxtest.xinet.kr | more % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to nginxtest.xinet.kr port 443 (#0) * Trying 112.175.245.208... * Connected to nginxtest.xinet.kr (112.175.245.208) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * Server certificate: * subject: CN=nginxtest.xinet.kr * start date: 9월 20 05:57:18 2023 GMT * expire date: 10월 21 05:57:17 2024 GMT * common name: nginxtest.xinet.kr * issuer: CN=AlphaSSL CA - SHA256 - G4,O=GlobalSign nv-sa,C=BE > HEAD / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: nginxtest.xinet.kr > Accept: */* > < HTTP/1.1 200 OK < Server: nginx/1.21.6 < Date: Wed, 20 Sep 2023 08:05:20 GMT < Content-Type: text/html; charset=UTF-8 < Connection: keep-alive < X-Powered-By: PHP/8.1.2 |
버전을 1.3으로 강제 통신 테스트 진행
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
[root@localhost ~]# curl --tlsv1.3 --tls-max 1.3 -I -v -L https://nginxtest.xinet.kr | more % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to nginxtest.xinet.kr port 443 (#0) * Trying 112.175.245.208... 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- * Connected to nginxtest.xinet.kr (112.175.245.208) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * SSL connection using TLS_AES_256_GCM_SHA384 * Server certificate: * subject: CN=nginxtest.xinet.kr * start date: 9월 20 05:57:18 2023 GMT * expire date: 10월 21 05:57:17 2024 GMT * common name: nginxtest.xinet.kr * issuer: CN=AlphaSSL CA - SHA256 - G4,O=GlobalSign nv-sa,C=BE > HEAD / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: nginxtest.xinet.kr > Accept: */* > < HTTP/1.1 200 OK < Server: nginx/1.21.6 < Date: Wed, 20 Sep 2023 08:14:29 GMT < Content-Type: text/html; charset=UTF-8 < Connection: keep-alive < X-Powered-By: PHP/8.1.2 |