Contents of OCSP packets? - ssl

As far as I know, the web browser use OCSP packets to check if the incoming certificate (from a web server) is still valid or it is revoked.
I have some questions about it:
1- Am I Right about the OCSP?
2- Does the browser send a OCSP request for every incoming cert?
3- Where is the destication of these requests? Root CA?
Well, I monitor the data transmission on my network adapter using Wireshark and I catch the following request :
click to enlarge
[]1
Well, above observation added 3 more question to above questions:
4- I did a whois IP the destination IP and the result shows that it is a23-51-123-27.deploy.static.akamaitechnologies.com . Is it really a Root CA?
5- This request is sent in plain and is not encrypted with SSL protocol! Why? Can't it simply attacked with MITM attacks?
6- This packet contains issuerNameHash, issuerKeyHash and serialNumber only! Are they enough really?! Why hashed values sent?

That's a lot of questions to answer.
Web browser will check OCSP responder for certificate revocation information only if it is set (to do so) in the browser settings and only if there is URL to OCSP in the certificate to validate.
First a certificate chain is built. Each certificate in the chain (excluding root which is trusted in your certificate store, or not :) ) will be validated by OCSP (if conditions in "1" are met).
It's not RootCA for every certificate. Each certificate in chain could contain url to OCSP server. OCSP server certificate has to be issued by the CA that it is working for so each CA will have (could have, it is not a mandatory service) its dedicated OCSP server. OCSP request will go to the corresponding OCSP server based on the url from certificate being validated.
I don't know what that url is. But there is a OCSP server running at IP 23.51.123.27 according to the dump.
Because that is the way OCSP works :). There are only public information in the request so nothing that would require encryption. Response is signed by OCSP server issued by the same CA that issued validated certificate. Client can easily validate that the response was not tampered with (signature chech) and that it was issued by valid OCSP responder - again nothing to encrypt. Read RFC 6960 for more information.
Yes, it is enough information. Certificate is identified by serial number and issuer. OCSP responder provides service for the CA that issued its certificate so OCSP server can validate that the request is valid (same issuer). OCSP server can (but is is only an extension to OCSP protocol and not widely used AFAIK) send back thumbprint of the validated certificate. It is a confirmation that OCSP server knows about the certificate.

Related

Does haproxy support OCSP for client certificate validation

We are configuring HAProxy to force require Client Certificate Validation. This works well. However, we couldn't find much information about OCSP support specifically for client certificate validation. There are information about Certificate Revocation list and OCSP Stapling (which I believe is for server certificates).
So my questions are
1. Does HAProxy supports OCSP during client certificate validation?
and
2. If it is supported, can this be manually configured without requiring the OCSP URL included in the client certificate itself or possibly overriding the url on the server?
We are configuring HAProxy to force require Client Certificate Validation.
Please define exactly what Client Certificate Validation means to you. You say it works well, so my best guess is that you're generating client certificates and you have configured haproxy to require valid client certificates in order to access resources that haproxy is in front of.
However, we couldn't find much information about OCSP support specifically for client certificate validation. ... 1. Does HAProxy supports OCSP during client certificate validation?
No. That's quite simply "out of scope" for a server like haproxy. HAproxy only does OCSP stapling, and only then if you supply the OCSP response in the form of .ocsp files in the certificate directory. It's unusual to want haproxy to block TLS connections while it tries to get HTTP responses from each TLS certificate for all the reasons that OCSP stapling exists. Along those same lines, having haproxy block TLS connections from your clients while it tries to validate their certs via OCSP (or for that matter, CRLs) is not a good idea.
Update: See this thread on in the haproxy forums.

Where are the Certificate Revocation List (CRL) stores?

As far as I know and as it is mentioned here there are two main technologies for browsers to check the revocation status of a particular certificate: using the Online Certificate Status Protocol (OCSP) or looking up the certificate in a Certificate Revocation List (CRL).
Well, I know that there is some online OCSP servers or the OCSP method and the browser send a request there to check if the incoming certificate is revoked, but I don't have any idea about the CRL.
Where is the CRL? Is it a file in my system that updated after OCSP requests or it is a list in the web server that I'm trying to connect to?
Who updates it?
How do OCSP server check revocation? (I mean how does it update its database of revoked certificates?)
Note that I know I can see a cache of CRL using certutil -urlcache crl in command line. But it is a cache of it! Where is the real file?
Where is CRL? Is it a file in my system that updated after OCSP requests or it is a list in the web server that I'm trying to connect to?
CRL is a list provided by the certificate issuer. The list contains the serial numbers and the reason for revocation of the revoked certificates and is signed by the issuer (or some other directly or indirectly trusted CA). The original CRL file is created and stored at the issuer. It gets provided usually via http/https but other mechanism exists. To know which URL provides the CRL for a specific certificate look at the 'CRL Distribution Points' property of the certificate. Note that lots of certificates issued by the same CA share the same CRL distribution point.
Where the local copy of the CRL is on your system, in which format it is stored there etc depends on the OS, browser, libraries... I doubt that it will be updated based on OCSP responses because OCSP and CRL are independent mechanism to check for revocation and a client usually only uses one of these to check for revocation of specific certificates. But it might use OCSP in some cases and CRL in other cases (where no OCSP is provided).
Who it updates?
It depends. Browsers usually don't use CRL's anymore but moved to OCSP, skip revocation checks completely or moved to some other mechanism like CRLSets. If any other application use CRL for the certificates - it probably depends on the application.
How OCSP server check revocation? (I mean how it update its database of revoked certificates?)
It does not check for revocation. Either the OCSP server is provided by the certificate issuer itself which already has the list of revoked certificates (since the issuer revoked these itself) or in case of OCSP stapling the web server gets the (signed) OCSP response from the issuer and includes it unchanged inside the TLS handshake.
In theory one could build some OCSP proxy which provides OCSP responses based on existing CRL files but since the OCSP responses are signed too this proxy must have a certificate which is explicitly trusted for signing OCSP responses.

mTLS ( mutual TLS) details

I know that for MTLS , both parties , Client and server exchange certificates. These certificates should be signed by a CA that both parties can trust in order to validate the certificate.
My question is , does MTLS also means in addition to verifying the certificate (if CA is trusted, leaf certificate is trusted) , either side (Server or client) can also do some additional checks like Hostname check or Whether the client connecting to the server is in the list of approved trusted entities?
Can anyone point me to the mTLS specification and what are the overheads in mTLS?
Besides what EJP has said about "MTLS" term, the TLS 1.2 specification doesn't have strict requirements regarding what information is to be checked and in which way.
It's up to the receiving party to decide if the presented certificate is to be trusted or not. This means that for example it's ok for the server to accept only certificates issued by the CA that belongs to the company that owns the server. This is how client-bank access systems often work - they accept only certificates issued by the bank and the common name of such certificate must correspond to the username provided in a web form.
Both parties are free to check any information in the certificate including direct comparison of public key hash (thus only particular keypairs will work no matter what is contained in other certificate properties).
The most up todate RFC regarding this subject is:
https://datatracker.ietf.org/doc/draft-ietf-oauth-mtls/
this is an extension to OAuth 2.0
The purpose of this document is to define a mechanism how TLS certificate is used in a context of replacing Client ID and Secret (aka, Client Credentials)
The standard establishes two mechanisms how a TLS Certificate is used as a client credential, and the associated token flows, and attributes.
The general summary of this is:
(a) Authorization Server: checks the certificate either according to PKI (signed by a valid root) The RFC does not define the options, but they are pretty self-explanatory and depend on the use case. But it can be (1) certificate is signed by a trusted root and, is not revoked, (2) individually recognize each certificate based on some logic.
(b) Resource server checks the token and client certificate (client credential, or CC), and used in the underlying TLS session. Please note that there are no validation checks concerning the certificate or its origin at TLS layer, all checks are performed at an Application layer. The resource server should, therefore, configure the TLS stack in a way that it does not verify whether the certificate presented by the client during the handshake is signed by a trusted CA certificate.
This mechanism becomes particularly interesting in some GDPR context, as it makes it impossible to share tokens between client and the server.
Overall a great feature for privacy, and improved security.
mTLS can be implemented by issuing all parties a CA certificate and adding these to all communicating parties, which is a sort of an access control list. Whoever has their CA certificate in your app's trust store is able to connect.
The trust system however is the same as with TLS in the case of a https connection - you can issue several certificates from the same CA and add the root CA certificate to the trust store of your app. It will trust all certificates issued from the same root. This is arguably easier to set up as you only have to add the app's own certificate and the CA root. However, if you want to revoke a certificate, it becomes a little more complicated.
I wrote a guide to generate certificates here:
https://thoughts-about-code.blogspot.com/2021/12/creating-a-ca-for-mtls-with-openssl.html
First:
Both server and client certificates have to be built with the same CA certificate and key
see : https://github.com/ysimonx/mtls-ssl-generator/blob/main/generate_certificates.sh
So you have to store the CA certificate on both sides :
On the server side : you can allow (this is optional) a client that provides client cert built with the same CA than its own certificate. (see rejectUnauthorized: true)
https: {
requestCert: true,
rejectUnauthorized: true,
key: fs.readFileSync("./certificates/server/serverKey.pem"),
cert: fs.readFileSync("./certificates/server/serverCrt.pem") ,
ca: [fs.readFileSync("./certificates/ca/caCrt.pem")]
}
(exemple for a fastify nodejs https self-signed certificate server)
On the client side : you can allow (this is optional too) a server that provides (or not) the same CA certificate as the client knows
curl -k --cert ./certificates/client/clientCrt.pem --key ./certificates/client/clientKey.pem https://localhost:3000/
(parameter -k : do not verify the server certificate based upon a CA authority)
or
curl --cacert ./certificates/ca/caCrt.pem --cert ./certificates/client/clientCrt.pem --key ./certificates/client/clientKey.pem https://localhost:3000/
if you want the client to match the correct CA cert used by the server
There is no 'MTLS Specification', for the very good reason that there is no such thing as 'MTLS'. You just made it up. The TLS specification, including mutual authentication, is to be found in RFC 2246 as amended.
The TLS APIs should make the peer certificate chain available to the application, so it can do any additional checking it likes.
'MTLS', insofar as it exists at all, refers to an Internet Draft for multiplexed TLS.

OCSP: How does verifier know which OCSP server to use?

I had trouble confirming this online- Are the OCSP server URLs specified in the X509 certificate of the CA, like CRLs, or must they specified out of band by the network administrator? How does the verifier know which OCSP server to use to verify a given certificate (assuming we have its certificate path)?
The Authority Information Access (AIA) details in an X.509 certificate will describe the location of the OCSP server.
The certificate authority that issued the certificate will had added the OCSP information to the certificate issued to the entity. The requester of the certificate has no choice over this and thus cannot hide the presence of the OCSP server.
OCSP clients can parse the certificate, note the presence of an OCSP AIA entry and make the validation request.

SSL Certificates and browser to web-server connectivity

I am sure this is embedded in the details of the SSL certificate/HTTPS specs but I am not entirely grokking this subject.
If a modern browser connects to a HTTPS site, the body of the HTTP request is encrypted. Is the SSL certificate essentially the "public" key used to communicate back and forth between the client and server?
Couldn't a hacker get the public key from the public site, say "https://www.google.com" and monitor client/server traffic and decrypt the data?
Also, do clients need to verify the "issuer" of a certificate. For example, self sign certificates clients don't need to verify but for certificates provided from a trusted issuer, what happens during the certificate verification process?
The server's certificate contains a public key which in fact is visible to everybody. This key in turn is used during the handshake between the server and client in order to create a unique session key that will be used to encrypt any further messages:
http://en.wikipedia.org/wiki/Secure_Sockets_Layer#TLS_handshake_in_detail
Couldn't a hacker get the public key from the public site, say
"https://www.google.com" and monitor client/server traffic and decrypt
the data?
The hacker won't know the session key. He will be listening to (senseless) encrypted stuff.
Also, do clients need to verify the "issuer" of a certificate. For
example, self sign certificates clients don't need to verify but for
certificates provided from a trusted issuer, what happens during the
certificate verification process?
Like you said, the issuer of the certificate is verified against a pre-defined list of trusted authorities. Any certificate up in the chain will be verified too, including the trusted issuer, expiration dates. Additionally each certificate contains URLs that point to Certificate Revocation Lists (CRL Distribution Points), the client will attempt to download the list from such URL and ensure the certificate at hand has not been revoked.