·터미널 명령어

openssl s_client

네트워크

쓰는 꼴

openssl s_client -connect <host>:443 -servername <host>

TLS 연결을 맨손으로 열어 인증서와 악수 과정을 들여다봅니다 — `-servername`을 빼면 한 IP에 여러 사이트가 있는 서버가 기본 인증서를 내주어 "엉뚱한" 것이 보이고, `< /dev/null`을 붙이지 않으면 입력을 기다리며 멈춰 있습니다.

자주 쓰는 옵션

옵션
-connect host:443Where to open the TLS connection.
-servername <host>The SNI name. Without it a shared host serves its default certificate.
-showcertsPrint the whole chain the server sent, not just the leaf.
-tls1_2 / -tls1_3Force one protocol version, to test what the server still accepts.
-verify_return_errorFail instead of continuing when the chain does not validate.
< /dev/nullClose stdin, or the command sits and waits forever.

예시

openssl s_client -connect example.com:443 -servername example.com < /dev/null 2>/dev/null | openssl x509 -noout -dates

When the certificate expires.

openssl s_client -connect example.com:443 -showcerts < /dev/null

Inspect the full chain for a missing intermediate.

연결이 안 될 때 어디까지 갔는지 좁혀 갑니다 — 이름이 안 풀리는지, 길이 없는지, 포트가 막혔는지.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. openssl s_client은 무엇을 하나요?

TLS 연결을 맨손으로 열어 인증서와 악수 과정을 들여다봅니다 — `-servername`을 빼면 한 IP에 여러 사이트가 있는 서버가 기본 인증서를 내주어 "엉뚱한" 것이 보이고, `< /dev/null`을 붙이지 않으면 입력을 기다리며 멈춰 있습니다.

Q. 어떻게 치나요?

openssl s_client -connect <host>:443 -servername <host> — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 6개입니다. 전체 목록은 man openssl에 있습니다. 이 명령은 네트워크 갈래입니다.

같이 보는 명령

man 페이지: man openssl-s_client