Nginx – OCSP with nginx is unable to get issuer certificate

nginxocsp

I am having trouble setting up OCSP on nginx/1.6.2 with a certificate issued by GlobalSign. I read many related posts, but none of the solutions I've found worked. When I connect to the server, OCSP is not working

> openssl s_client -connect cawi.kondeor.at:443 -tls1 -tlsextdebug -status
[...]                                             .
OCSP response: no response sent
depth=2 C = BE, O = GlobalSign nv-sa, OU = Root CA, CN = GlobalSign Root CA
verify return:1
depth=1 C = BE, O = GlobalSign nv-sa, CN = GlobalSign Domain Validation CA - SHA256 - G2
verify return:1
depth=0 OU = Domain Control Validated, CN = cawi.kondeor.at
verify return:1
---
Certificate chain
 0 s:/OU=Domain Control Validated/CN=cawi.kondeor.at
   i:/C=BE/O=GlobalSign nv-sa/CN=GlobalSign Domain Validation CA - SHA256 - G2
 1 s:/C=BE/O=GlobalSign nv-sa/CN=GlobalSign Domain Validation CA - SHA256 - G2
   i:/C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA
---
Server certificate
-----BEGIN CERTIFICATE-----
[...]
-----END CERTIFICATE-----
subject=/OU=Domain Control Validated/CN=cawi.kondeor.at
issuer=/C=BE/O=GlobalSign nv-sa/CN=GlobalSign Domain Validation CA - SHA256 - G2
---
No client certificate CA names sent
---
SSL handshake has read 2944 bytes and written 372 bytes
---
[...]
---

and the nginx log shows following error:

[error] 10646#0: OCSP_basic_verify() failed (SSL: error:27069065:OCSP routines:OCSP_basic_verify:certificate verify error:Verify error:unable to get issuer certificate) while requesting certificate status, responder: ocsp2.globalsign.com

All other posts I've found were related to the error Verify error:unable to get LOCAL issuer certificate which was solved by fixing the certificate chains.
My certificate chains seem to be okay, as the openssl ocsp command works (but only if I use the -header "HOST" "ocsp2.globalsign.com" parameter due to the CDN):

> openssl ocsp -issuer root_ca_and_intermediate.pem -cert signed_cert_and_intermediate.pem -url http://ocsp2.globalsign.com/gsdomainvalsha2g2 -CAfile root_ca_and_intermediate.pem -header "HOST" "ocsp2.globalsign.com" -resp_text
OCSP Response Data:
    OCSP Response Status: successful (0x0)
    Response Type: Basic OCSP Response
    Version: 1 (0x0)
    Responder Id: 32B1CE1488C41C77C67D0B2DAEFE569D3A5F4E69
    Produced At: Sep 12 20:46:48 2016 GMT
    Responses:
    Certificate ID:
      Hash Algorithm: sha1
      Issuer Name Hash: D1F1B576F9EEC0C10F7AFC7C3124A9C3625D7C61
      Issuer Key Hash: EA4E7CD4802DE5158186268C826DC098A4CF970F
      Serial Number: 1121CD2E68A5AE7FEF7A719EDD4AE4034F8B
    Cert Status: good
    [...]
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            14:dd:f1:f0:75:30:57:18:61:ec:c0:2c
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: C=BE, O=GlobalSign nv-sa, CN=GlobalSign Domain Validation CA - SHA256 - G2
        Validity
            Not Before: Jul 25 03:28:41 2016 GMT
            Not After : Oct 25 03:28:41 2016 GMT
        Subject: C=BE, O=GlobalSign nv-sa/serialNumber=201607251137, CN=GlobalSign Domain Validation CA - SHA256 - G2 - OCSP Responder
        [...]
-----BEGIN CERTIFICATE-----
[...]
-----END CERTIFICATE-----
Response verify OK
signed_cert_and_intermediate.pem: good
    This Update: Sep 12 20:46:48 2016 GMT
    Next Update: Sep 16 20:46:48 2016 GMT

A cleaned up version of my nginx configuration can be found here: http://pastebin.com/KYujwSgS

Can Cloudflare be the issue here or did I overlook something?
Any help is greatly appreciated!

Best Answer

Thanks for all the comments! It made me look carefully at the certificate chains again and I noticed I did not put the root CA certificate into the file root_ca_and_intermediate.pem but the intermediate certificate twice.

So the working setup now is that the file signed_cert_and_intermediate.pem contains the actual certificate for the site (first) and the intermediate certificate used to sign the actual certificate (second). The file root_ca_and_intermediate.pem contains the intermediate certificate (first) and the root CA certificate (second) that was used to sign the intermediate certificate.