We happen to run a REST API service that exposes an https://
endpoint. Recently we changed our SSL certificate and several users, mostly libcurl and Java users, complained that they no longer can validate the certificate and their programs refuse to connect to our service. Other users, including .NET users, didn't observe any problems. Firefox is also happy to open pages on the site with that certificate.
We need to craft some code that validates the certificates the hardest way possible before we use them in production.
I crafted a piece of code that creates a X509Certificate2
object for the certificate and then tries to X509Chain.Build()
from it:
var certDataArray = File.ReadAllBytes( path );
var cert = new X509Certificate2( certDataArray, password );
var chain = new X509Chain();
var result = chain.Build(cert);
var status = chain.ChainStatus;
This code runs okay for our previous certificate (which is not yet expired) and fails (Build()
returns false
and X509Chain.ChainStatus
contains a number of elements - X509ChainStatusFlags.RevocationStatusUnknown
, X509ChainStatusFlags.PartialChain
, X509ChainStatusFlags.OfflineRevocation
). So it looks like for this specific certificate this check is enough.
Is X509Chain.Build()
enough to ensure that all of our users can successfully validate the certificate? Are any other checks necessary?