Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error querying OCSP responder #1056

Closed
drwetter opened this issue May 17, 2018 · 9 comments
Closed

error querying OCSP responder #1056

drwetter opened this issue May 17, 2018 · 9 comments
Labels
Milestone

Comments

@drwetter
Copy link
Collaborator

drwetter commented May 17, 2018

PR #1055 brought OCSP revocation checks (merged in crl_ocsp branch), see also #254. I added a host header to the query but still the feature doesn't seem to be production ready yet :-(

The first 1169 nodes (Alexa ranking) with TLS replies on port 443 TCP:

  • 336 still return error querying OCSP responder (305 with Code=400, 31 without any code returned).
  • 152 of 336 are showing a Google responder (pki.goog)
  • 833 are fine.

This issue is just informational.

@drwetter drwetter added this to the 3.0 milestone May 17, 2018
@dcooper16
Copy link
Contributor

Hi Dirk,

Thanks for the improvements that you made to the code that I submitted. I thought it was in fairly good shape, but that it could use some improvements, which is why I submitted it for the crl_ocsp branch rather than the 2.9dev branch. I didn't test as many sites as you did, but it seemed to at least pass the initial test of not reporting any incorrect results. It seemed that the code would either report the correct result (revoked or not revoked) or it wouldn't print anything at all.

My testing produced mixed results. I tested the code against several sites using parallel mass testing, and then ran individual tests in debug mode for any server that didn't print a result during mass testing. It seemed that in every case, however, that the individual test resulted in a response of "not revoked."

To some degree we are going to have to accept less than perfection on these tests. There is a reason that browsers have basically given up on using CRLs or OCSP to check server certificates, and that even when they did try to check CRLs or OCSP, the browsers would be configured to accept a certificate as valid if no revocation information could be obtained. It is my understanding that the sources of revocation information just weren't reliable enough to treat the inability to obtain revocation information as a hard failure.

@drwetter
Copy link
Collaborator Author

I would at least to understand the 400s which is probably the HTTP server status. The logic that it's "our problem" seems to me too far away yet. Why would a certificate issue operate a server which is broken and put this URI into the certificates.

Thanks for the improvements that you made to the code that I submitted. I thought it was in fairly good shape, but that it could use some improvements, which is why I submitted it for the crl_ocsp branch rather than the 2.9dev branch.

In fact I did realize this (with a smile) and I appreciate you seem always to pay a lot of attention what you're doing 👍

My testing produced mixed results. I tested the code against several sites using parallel mass testing, and then ran individual tests in debug mode for any server that didn't print a result during mass testing. It seemed that in every case, however, that the individual test resulted in a response of "not revoked."

I need to pass to you tomorrow the servers I tested. Two servers I remembered off the top of my head: ca.gov, sourceforge.net .

As far as the currently technology is concerned, I fully agree. CRL is dead since a long time for browsers -- wasn't handy anyway. OCSP revocation checking seems still enabled in FF 60 though. For other clients, also non-browsers, I can't tell. In any case as long as this is in widespread use, it makes sense to support this feature.

drwetter added a commit that referenced this issue May 18, 2018
My previous commit added a host header but didn't properly
format the host header (trailing slashes / path). This commit
corrects that so that the 305 times HTTP 400 in #1056
should now be gone (TBC), including Google CA responders.

One issue which needs to be addressed (same as in CRL
revocation checks): Not trusted certificates (zhanqi.tv,
taken from my Alexa scans) fail for obvious reasons.
@drwetter
Copy link
Collaborator Author

Fixed the major error, see commit message.

More later.

@drwetter
Copy link
Collaborator Author

I merged the crl_ocsp branch. Despite my commit message there are still a few errors (used the wrong grep pattern) checking with the OCSP.

Notably some errors were expedia.com and mozilla.com, probably because of chain issues. The latter is not reproducible anymore (has a new certificate). The first is.

More later.

@dcooper16
Copy link
Contributor

For sites such as expedia.com the only solution is to not run the test, or at least not print out any results. When sending an OCSP query, you need to provide the following information for each certificate that you are asking about:

   CertID          ::=     SEQUENCE {
       hashAlgorithm       AlgorithmIdentifier,
       issuerNameHash      OCTET STRING, -- Hash of Issuer's DN
       issuerKeyHash       OCTET STRING, -- Hash of Issuers public key
       serialNumber        CertificateSerialNumber }

In the case of expedia.com, the server only sends its own certificate. Without any other certificates, we cannot provide the ocsp command with a copy of the issuer's public key. Without that, the ocsp command cannot generate the issuerKeyHash and so cannot even create an OCSP request.

The way the code is written, it will only work if the server provided more than one certificate:

     $OPENSSL ocsp -no_nonce -header Host ${host_header} -url "$uri" \
          -issuer $TEMPDIR/hostcert_issuer.pem -verify_other $TEMPDIR/intermediatecerts.pem \
          -CAfile $TEMPDIR/intermediatecerts.pem -cert $HOSTCERT -text &> "$tmpfile"

$TEMPDIR/intermediatecerts.pem contains the certificates (other than the server's certificate) that were sent by the server, and $TEMPDIR/hostcert_issuer.pem contains the first certificate from $TEMPDIR/intermediatecerts.pem. If $TEMPDIR/intermediatecerts.pem is empty, then $TEMPDIR/hostcert_issuer.pem won't be available, and the ocsp command needs that file in order to create issuerKeyHash.

In theory, if the server didn't provide any intermediate certificates, but the server's certificate was issued by one of the CAs in etc/Apple.com, etc/Linux.pem, etc/Microsoft.pem, or etc/Mozilla.pem, we could get the certificate needed for the -issuer option from one of those files, but trying to do that would be infeasible. Besides, in the case of expedia.com the chain of trust is "NOT ok", so even that wouldn't work.

dcooper16 added a commit to dcooper16/testssl.sh that referenced this issue May 29, 2018
This PR fixes problems with check_revocation_crl() sometimes reporting that a certificate is revoked even when it isn't, and with check_revocation_ocsp() sometimes reporting "error querying OCSP responder" even if the OCSP responder provided a good response. The most common reason for this to happen is that OpenSSL cannot validate the server's certificate (even without status checking). PR testssl#1051 attempted to get status checking to work even in cases in which the server's certificate could not be validated. This PR instead addresses the problem by not checking status if determine_trust() was unable to validate the server's certificate.

In some cases the server's certificate can be validated using some, but not all of the bundles of trusted certificates. For example, I have encountered some sites that can be validated using the Microsoft and Apple bundles, but not the Linux or Mozilla bundles.

This PR introduces GOOD_CA_BUNDLE to store a bundle that could be used to successfully validate the server's certificate. If there is no such bundle, then neither check_revocation_crl() nor check_revocation_ocsp() is run. When check_revocation_crl() and check_revocation_ocsp() are called, the status checks within them closely match the validation check in determine_trust(), which helps to ensure that if the check fails it is because of the status information.

As noted in testssl#1057, at least one CA provides incorrect information when the CRL is downloaded, so validation could fail for a reason other than the certificate being revoked. So, this PR adds a check of the reason that validation failed and only reports "revoked" if the validation failed for that reason.

As noted in testssl#1056, it is not possible to perform an OCSP query without access to the certificate issuer's public key. So, with this PR check_revocation_ocsp() is only called if the server's provided at least one intermediate certificate (i.e., the issuer's certificate, which contains the issuer's public key).
@drwetter
Copy link
Collaborator Author

Expedia is another exception for the rest see #1057 (comment). Thus closing it.

@egberts
Copy link

egberts commented Oct 20, 2020

Mmmmm, is it me or is it LetsEncrypt?

$ cd github/testssl.sh

$ OSSL_SHORTCUT=true ./testssl.sh --openssl=/usr/bin/openssl egbert.net

 Certificate Revocation List  --
 OCSP URI                     http://ocsp.int-x3.letsencrypt.org
 OCSP stapling                offered, error querying OCSP responder (ERROR: No Status found)
 OCSP must staple extension   --

Running the "latest" testing OpenSSL.

###########################################################
    testssl.sh       3.1dev from https://testssl.sh/dev/
    (4af9016 2020-10-20 21:00:02 -- )
 Using "OpenSSL 1.1.1d  10 Sep 2019" [~98 ciphers]
 on ns1:/usr/bin/openssl
 (built: "Apr 20 20:23:01 2020", platform: "debian-amd64")

Note: You have permission to run TLS-based tools against this site.

@drwetter
Copy link
Collaborator Author

can't tell, works for me.

In general: Thx for the permission but I assume when hostnames are not redacted I have the permission to scan. Also be aware this is a public space in the internet, so others probably will do that too if they are bored and have no pet or child to play with ;-)

@egberts
Copy link

egberts commented Oct 21, 2020

It’s OSINT-blockable for those who abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants