大网数据广告活动
服务器运维问答

LetsEncrypt: Unknown SSL protocol error in connection

· 52CE 我爱测

I have a host with LE certificate and it works well in a browsers, but I still can't connect using curl , openssl , wget , POST (libwww-perl): curl # curl -v -3 https://example.com/ * Hostname was NOT found in DNS cache * Trying …

问题原文

原帖链接 · Serhii Matrunchyk · CC BY-SA 3.0

I have a host with LE certificate and it works well in a browsers, but I still can't connect using curl, openssl, wget, POST (libwww-perl):

curl

# curl -v -3 https://example.com/
* Hostname was NOT found in DNS cache
*   Trying 123.123.123.123...
* Connected to example.com (123.123.123.123) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to example.com:443 
* Closing connection 0

openssl

# openssl s_client -connect example.com:443
CONNECTED(00000003)
write:errno=104
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 295 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
---

wget

# wget --post-data "key=val" -vvv https://example.com/
--2016-05-11 11:19:01--  https://example.com/
Resolving example.com (example.com)... 123.123.123.123
Connecting to example.com (example.com)|123.123.123.123|:443... connected.
Unable to establish SSL connection.

POST

# echo 'key=val' | POST https://example.com:443 
Can't connect to example.com:443

LWP::Protocol::https::Socket: SSL connect attempt failed with unknown error SSL wants a read first at /usr/share/perl5/LWP/Protocol/http.pm line 41, <STDIN> line 1.

Vhost Config:

<VirtualHost *:443>
  ServerName example.com
  SSLEngine On
  SSLProtocol ALL -SSLv2 -SSLv3
  SSLHonorCipherOrder On
  SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
  SSLVerifyDepth 10
  SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/example.com/fullchain.pem
  DocumentRoot "/var/www/"
</VirtualHost>

已采纳解答

原帖链接 · MadHatter · CC BY-SA 3.0

I think your problem is DNSSEC-related. There exists a DS record for the zone:

[me@risby ~]$ dig ds codestronaut.com
[...]
;; ANSWER SECTION:
codestronaut.com.       86363   IN      DS      19465 8 1 42AFC90FE0A61D3993051C55B6C4C35518713921

but the A record for chat is unsigned:

[me@risby ~]$ dig +dnssec +trace chat.codestronaut.com
[...]
codestronaut.com.       172800  IN      NS      dns1.yandex.net.
codestronaut.com.       172800  IN      NS      dns2.yandex.net.
codestronaut.com.       86400   IN      DS      19465 8 1 42AFC90FE0A61D3993051C55B6C4C35518713921
codestronaut.com.       86400   IN      RRSIG   DS 8 2 86400 20160517050727 20160510035727 34745 com. Xk/mK5Y8LigJyP+iPF9arhZXKmsDvslfigom/7BZ2orIKHFGAX8/Q9eE O4rRCZPQD82WBssFHf/jcYSUiZrF/j6Ovq4sPbOJbjPUUoHlkOb8uGe/ 3erv6snM8SKVu8eSaE42cj8efvNRZR4S1MMesD5HGG1gMzjQLkTvHiEN wmE=
;; Received 329 bytes from 192.54.112.30#53(h.gtld-servers.net) in 18 ms

chat.codestronaut.com.  21600   IN      A       95.158.40.23
;; Received 66 bytes from 2a02:6b8::213#53(dns1.yandex.net) in 66 ms

Note the lack of an RRSIG record for chat.codestronaut.com. This causes DNS lookups simply to fail on certain platforms:

[me@risby ~]$ curl https://chat.codestronaut.com
curl: (6) Could not resolve host: chat.codestronaut.com

I don't thnk there's much chance of getting all this to work reliably until you fix your DNS; either have your registrar stop publishing a DS record for the zone, or sign your zone properly. I'm not saying this is the only problem you have, but having a working DNS is pretty much a pre-requisite for everything else, and that includes debugging.

Edit: you say you've disabled DNSSEC, but the change has not yet propagated (it may take up to a day, since the TTL on your old DS record was 86400s). Using a DNSSEC-blind client, I can't reproduce the problems you report, but I note that you're running SNI on that system (ie, several SSL certificates are available, including both chat.codestronaut.comand panel.codestronaut.com).

curl -v -3 explicitly doesn't support SNI (because SNI is an extension to TLS, and thus isn't available in SSLv3). openssl s_client works OK once it's warned about SNI:

[me@lory tmp]$ openssl s_client -connect chat.codestronaut.com:443 -servername chat.codestronaut.com
[...]
Certificate chain
 0 s:/CN=chat.codestronaut.com
   i:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X1
 1 s:/CN=chat.codestronaut.com
   i:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X1
 2 s:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X1
   i:/O=Digital Signature Trust Co./CN=DST Root CA X3

though without the SNI flag (-servername ...) it gets the certificate for panel. instead.

So at the moment your original report "it works well in a browsers, but I still can't connect using [other tools]" seems to boil down to "it works fine, except when I connect using tools that aren't supposed to work on this setup". This is looking a bit like a non-problem.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。