我在使用中间CA(自行创build)时遇到了一些nginx客户机authentication的困难。
尽pipe相同的证书包(单个.pem文件中的中间+根证书)适用于IMAP(dovecot)和SMTP(后缀)中的客户端身份validation,但我似乎无法使其与nginx一起使用。 相反,我得到以下错误:
[info] 23383#23383: *14583139 client SSL certificate verify error: (27:certificate not trusted) while reading client request headers, client: 82.39.81.156, server: <hostname>, request: "GET /mailboxes HTTP/1.1", host: "<hostname>"
据我了解,来自openssl的错误types27是X509_V_ERR_CERT_UNTRUSTED ,或某种特定用途的证书不可信的问题,但是我无法再详细说明。
个人和捆绑的证书似乎都用openssl verifyvalidation正确openssl verify (我可以validation客户端证书对中间或捆绑,中间证书validation根证书,即在我能想到的每个组合中都是有效的)。
为了validation我的客户端证书,我的根和中间CA应该使用正确的扩展名进行设置,以下是我的自定义openssl.conf文件的相关示例:
[ v3_ca ] # Extensions for a typical CA (`man x509v3_config`). subjectKeyIdentifier = hash authorityKeyIdentifier = keyid:always,issuer basicConstraints = critical, CA:true keyUsage = critical, digitalSignature, cRLSign, keyCertSign [ v3_intermediate_ca ] # Extensions for a typical intermediate CA (`man x509v3_config`). subjectKeyIdentifier = hash authorityKeyIdentifier = keyid:always,issuer basicConstraints = critical, CA:true, pathlen:0 keyUsage = critical, digitalSignature, cRLSign, keyCertSign
同时,我发布的客户端证书被configuration为对客户端身份validation和电子邮件encryption/签名如此工作:
[ user_cert ] # Extensions for client certificates (`man x509v3_config`). basicConstraints = CA:FALSE nsCertType = client, email nsComment = "OpenSSL Generated Client Certificate" subjectAltName = email:move subjectKeyIdentifier = hash authorityKeyIdentifier = keyid,issuer keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment extendedKeyUsage = critical, clientAuth, emailProtection
(的确,如果它们设置不正确,那么OS X的Safari和Mail不会让我发送它们,因为它们往往是非常严格的)。
许多类似的问题build议将ssl_verify_depth设置为2(以validation中间证书和根证书),但这似乎没有帮助。
我有相同的设置,并一直试图诊断这个确切的问题。 证书在apache实例上工作得很好,但nginx是一个问题。 这是我提出的解决scheme。
将您的ssl_client_certificate指向您的根证书。 不是你的中间人。 然后,确保nginxvalidation深度为2.我已经尝试了一个证书链文件作为客户端证书的参数,它仍然没有工作。 我不明白为什么它必须是根,而不是签署证书的中间人。 但是这个工作。
为了完整起见,下面是我的nginxconfiguration的相关部分:
server { listen 8443 ssl; server_name www.example.com; ssl on; ssl_certificate /path/to/cert.pem; ssl_certificate_key /path/to/key.key; ssl_client_certificate /path/to/root.ca.cert; ssl_verify_client on; ssl_verify_depth 2; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers <snipped-for-length>; }