[이슈] curl (35) tcp connection reset by peer

문정환·2023년 9월 20일

"curl (35) tcp connection reset by peer"

  • 오류는 일반적으로 TCP 연결이 응답을 받기 전에 서버 또는 네트워크 측에서 종료되거나 재설정되었음을 나타냅니다

원인

  • 위 오류 메시지는 curl을 사용하여 YOUR_URL의 443번 포트로 연결을 시도했으나, 서버와 클라이언트 간의 공통된 암호화 알고리즘이 없기 때문에 안전한 연결을 협상할 수 없다는 것을 나타냅니다. 이러한 오류는 대개 서버 및 클라이언트 구성 불일치로 인해 발생
**# 문제 발생 curl 버전**
# curl --version

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

**# 문제 없는 curl 버전**
# curl --version
curl 7.79.1 (Windows) libcurl/7.79.1 Schannel
Release-Date: 2021-09-22
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS HSTS IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI UnixSockets

해결책

  • 이 문제는 클라이언트와 서버 간의 SSL/TLS 연결을 협상할 수 있는 암호화 알고리즘이 없어 발생하는 오류입니다. 이러한 오류는 대개 클라이언트 또는 서버 구성의 문제로 인해 발생합니다.
  • 이 경우에는 오래된 NSS 라이브러리 사용으로 인한 오류 였으며, 해당 라이브러리 업데이트를 제안해서 해결

References

# CentOS version 6.5.
# Please note: 
# I can correctly connect to https://encrypted.google.com but unsuccessful with https://api.twitter.com.

# Issue ended up being that our server running the REST API was RHEL 6.6, using a newer version of NSS. Once we upgraded the client NSS version curl was successful.
# We upgraded the client from: nss-3.12.10-2.el6_1.x86_64
# nss-3.16.1-14.el6

# curl https://YOUR_URL --tlsv1.3 -v -L
* About to connect() to YOUR_URL port 443 (#0)
*   Trying ::1...
* Connected to YOUR_URL (::1) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -12286 (SSL_ERROR_NO_CYPHER_OVERLAP)
* Cannot communicate securely with peer: no common encryption algorithm(s).
* Closing connection 0
curl: (35) Cannot communicate securely with peer: no common encryption algorithm(s).

다른 방안

  1. 도메인 URI로 호출 테스트 ex) devops.moon.co.kr/login
  2. 다른 도메인으로 curl 호출 테스트 ex) grafana.com
  3. curl과 같은 기능을 하는 REST API 호출 도구 사용
# curl을 사용하여 HTTP 요청 보내기
curl https://www.google.com

# wget을 사용하여 HTTP 요청 보내기
wget -O- https://www.google.com

# httpie를 사용하여 HTTP 요청 보내기
http GET https://www.google.com

# 약식 호출
curl -Is https://devops.moon.co.kr

# 인증서 정보 확인
openssl s_client -connect devops.moon.co.kr:443
profile
All-rounder

0개의 댓글