我正在尝试使用StartSSL证书设置Nginx(1.4.6-1ubuntu3.1).我一直在关注the documentation以使其正常工作,但Nginx仅提供服务器证书,而不是中间件.
我的服务器配置:
server {
server_name lanzz.org www.lanzz.org;
root /var/www/lanzz.org/public;
index index.html;
include listen.conf;
ssl_certificate /etc/ssl/Nginx/lanzz.org.chained.pem;
ssl_certificate_key /etc/ssl/Nginx/lanzz.org.key;
}
我的证书包(/etc/ssl/Nginx/lanzz.org.chained.pem):
-----BEGIN CERTIFICATE-----
MIIGMzCCBRugAwIBAgIDE5WyMA0GCSqGSIb3DQEBCwUAMIGMMQswCQYDVQQGEwJJ
TDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0
YWwgQ2VydGlmaWNhdGUgU2lnbmluZzE4MDYGA1UEAxMvU3RhcnRDb20gQ2xhc3Mg
MSBQcmltYXJ5IEludGVybWVkaWF0ZSBTZXJ2ZXIgQ0EwHhcNMTQxMDE0MTMzNjI1
WhcNMTUxMDE1MTUzODI3WjBKMQswCQYDVQQGEwJHQjEWMBQGA1UEAxMNd3d3Lmxh
bnp6Lm9yZzEjMCEGCSqGSIb3DQEJARYUcG9zdG1hc3RlckBsYW56ei5vcmcwggEi
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCs8AMEaHFRZ4S3gGYhDJg05vj3
EadGIi29EJf5iW1YwKduuA62Zv9D2JGh2FCBJDBTswefxFbs2v/HHdP70gr0l669
Vz47RUJgn6xH13xEnVv5btQfPtioLQJNwLnBDR3ycw+9I/CGq+/BmStXBT2fTlDp
7FlDaemkc/mjd4TM6DBL0mfsAfqcSA4GHgQraJSwMyRGn3lon02mOWsDso6nTMEt
QYmCvYoM7wVtiBxKGP9Q6Nz3s5Ouc1U7mxKxuLNIO5ZeT+zocW7HQXk1sGal/Hxi
Y+Us/SsmcDAvqvI9f44Xe4StMfPDBphEDrOvJt9/zuDu8SNMnEA1cqZHGQFVAgMB
AAGjggLdMI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7LM9NfpMfULFWE7epTj69m8f5SuauNi
YpaoZHy4h/OZMn6SolK+u/hlz8nyMPyLwcKmltdfieFcNID1j0cHL7SRv7Gifl9L
WtBbnySGBVFaaQNlQ0lxxeBvlDRr9hvYqbBMflPrj0jfyjO1SPo2ShpTpjMM0InN
SRXNiTE8kMBy12VLUjWKRhFEuT2OKGWmPnmeXAhEKa2wNREuIU640ucQPl2Eg7PD
wuTSxv0JS3QJ3fGz0xk+gA2iCxnwOOfFwq/iI9th4p1cbiCJSS4jarJiwUW0n6+L
p/EiO/h94pDQehn7Skzj0n1fSoMD7SfWI55rjbRZotnvbIIp3XUZPD9MEI3vu3Un
0q6Dp6jOW6c=
-----END CERTIFICATE-----
openssl s_client -connect lanzz.org:443的输出:
CONNECTED(00000003)
depth=0 C = GB,CN = www.lanzz.org,emailAddress = postmaster@lanzz.org
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 C = GB,emailAddress = postmaster@lanzz.org
verify error:num=27:certificate not trusted
verify return:1
depth=0 C = GB,emailAddress = postmaster@lanzz.org
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
0 s:/C=GB/CN=www.lanzz.org/emailAddress=postmaster@lanzz.org
i:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 1 Primary Intermediate Server CA
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIGMzCCBRugAwIBAgIDE5WyMA0GCSqGSIb3DQEBCwUAMIGMMQswCQYDVQQGEwJJ
TDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0
YWwgQ2VydGlmaWNhdGUgU2lnbmluZzE4MDYGA1UEAxMvU3RhcnRDb20gQ2xhc3Mg
MSBQcmltYXJ5IEludGVybWVkaWF0ZSBTZXJ2ZXIgQ0EwHhcNMTQxMDE0MTMzNjI1
WhcNMTUxMDE1MTUzODI3WjBKMQswCQYDVQQGEwJHQjEWMBQGA1UEAxMNd3d3Lmx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5kZWQgcHVycG9zZSBpbiBjb21wbGlhbmNlIG9mIHRoZSByZWx5
aW5nIHBhcnR5IG9ibGlnYXRpb25zLjA1BgNVHR8ELjAsMCqgKKAmhiRodHRwOi8v
Y3JsLnN0YXJ0c3NsLmNvbS9jcnQxLWNybC5jcmwwgY4GCCsGAQUFBwEBBIGBMH8w
OQYIKwYBBQUHMAGGLWh0dHA6Ly9vY3NwLnN0YXJ0c3NsLmNvbS9zdWIvY2xhc3Mx
L3NlcnZlci9jYTBCBggrBgEFBQcwAoY2aHR0cDovL2FpYS5zdGFydHNzbC5jb20v
Y2VydHMvc3ViLmNsYXNzMS5zZXJ2ZXIuY2EuY3J0MCMGA1UdEgQcMBqGGGh0dHA6
Ly93d3cuc3RhcnRzc2wuY29tLzANBgkqhkiG9w0BAQsFAAOCAQEAEom5lVxCbfu9
3K+BuowfCgTyA4keiQcYmTUJYXRBV9OiFUc/V5tXyhmgdyYeJB3oKMaEQ3glClZm
ueXUkALhaIlEzXjoNZgOh/bdbBPwfOq2WMBaWJbXX3x4C77s52zPBbkqhsBq5nge
1YDho1Z7tVYe8iyqBPUIFq0//LfGVAMoR7ZSwVpUgeiWs3oVKQMyR2BzrNSq392L
f8kIdIQ8fTgomtCZ2F2qp8EBIxl6G4UVpeN3Nes9UODpdNeG6lzLoSvYsVX+eWXx
3m29Aem42vlMhtQL1dtahb71nTY26qWAG337fwQoRxAXht3vSs0HhdUEHyGQGsuu
k+fcnm/wiQ==
-----END CERTIFICATE-----
subject=/C=GB/CN=www.lanzz.org/emailAddress=postmaster@lanzz.org
issuer=/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 1 Primary Intermediate Server CA
---
No client certificate CA names sent
---
SSL handshake has read 2256 bytes and written 451 bytes
---
New,TLSv1/SSLv3,Cipher is ECDHE-RSA-AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1
Cipher : ECDHE-RSA-AES256-SHA
Session-ID: 958F818087118CA5F3344796B13FD463097B08ACF4F5497A3AD7A40D550FA155
Session-ID-ctx:
Master-Key: 3AB94A204BF8E30BEDC615832E7DD5B2347458A6324A85C8C02BD441AF9F39BA09191BEB85A5F40ED99049013A51F7AB
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 300 (seconds)
TLS session ticket:
0000 - 27 5f 93 a2 81 ed c3 e7-ba 41 27 0f 8f 95 be f5 '_.......A'.....
0010 - 68 a6 7a 8b 1a 84 71 6a-00 cd ec 94 fc 3f 2c 64 h.z...qj.....?,d
0020 - d8 b1 19 76 ba 8e ff e6-97 39 89 fb 1d 69 47 4a ...v.....9...iGJ
0030 - b3 40 96 a5 30 9e c6 b6-79 7f 93 36 02 31 4d 16 .@..0...y..6.1M.
0040 - 2b d9 d6 0b 3c a9 07 10-63 af 89 b2 19 0e ac b3 +...<...c.......
0050 - 3f c2 41 df f5 23 62 5c-11 d8 f6 be 55 1e e2 74 ?.A..#b\....U..t
0060 - 6c 4f cd ba 72 e1 a1 f7-b4 fb d1 19 6d 33 d5 63 lO..r.......m3.c
0070 - d6 94 a0 e6 e5 0c 33 e4-67 e3 49 fe fc b1 d5 25 ......3.g.I....%
0080 - 9d d7 d3 72 b4 fb 5a 1f-6e 7f 5e 4b 41 21 3a d5 ...r..Z.n.^KA!:.
0090 - 37 ef 4a b4 35 2d 14 bd-29 77 6d c5 6c c5 3c a4 7.J.5-..)wm.l.<.
Start Time: 1422525959
Timeout : 300 (sec)
Verify return code: 21 (unable to verify the first certificate)
---
如您所见,链中只存在一个证书,Nginx不提供中间证书.
我已经验证了Nginx看到了正确的捆绑包,因为如果我将服务器证书与中间证书交换,我确实看到了文档中提到的预期的SSL_CTX_use_PrivateKey_file错误.当我按正确的顺序放置它时,我看到启动时没有错误,请求时没有错误,但SSL会话中没有中间证书.
该链是正确的,因为我已经验证已经拥有中间件的浏览器将接受服务器证书,并且我已经验证了我在浏览器中看到的中间证书和服务器证书的指纹与我得到的相同.我服务器上的捆绑包中的证书.
我在这里完全失去了,我不知道还有什么可以尝试的.我认为一切都是由本书设置的,但我仍然没有在s_client中得到预期的结果.我找不到其他任何人甚至遇到这样的问题,更不用说任何现有的解决方案了.我甚至尝试在包中包含根证书,这对任何方面都没有影响.任何提示或指示将非常感激.
运行openssl s_client -connect lanzz.org:443:
CONNECTED(00000003)
depth=0 C = GB,emailAddress = postmaster@lanzz.org
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
0 s:/C=GB/CN=www.lanzz.org/emailAddress=postmaster@lanzz.org
i:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 1 Primary Intermediate Server CA
---
运行openssl s_client -connect lanzz.org:443-servername lanzz.org:
CONNECTED(00000003)
depth=1 C = IL,O = StartCom Ltd.,OU = Secure Digital Certificate Signing,CN = StartCom Class 1 Primary Intermediate Server CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=GB/CN=www.lanzz.org/emailAddress=postmaster@lanzz.org
i:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 1 Primary Intermediate Server CA
1 s:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 1 Primary Intermediate Server CA
i:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Certification Authority
---
显然,一方面我有一个默认的虚拟主机配置了错误的证书文件(一个没有中间),而另一方面,openssl s_client不会自动为传递给-connect参数的主机名提供SNI扩展. Nginx文档天真地提供了一个命令,它只测试默认虚拟主机的SSL设置,我认为这很少是人们通常想要的.
TL; DR:在测试SSL链时提供-servername参数:
openssl s_client -connect