Verifying certificate revocation can be a complex process. First you need to look for the CDP or OCIA AIA, then make a request, analyze the response and verify that the response is signed against a CA that is allowed to respond to this certificate. If it is a CRL, you need to find out if the serial number of the certificate you are checking is listed. If this is an OCSP, you need to find out if you received a “good” answer (as opposed to unknown, recalled, or any of the various OCSP responder errors, such as unauthorized ones). In addition, you can verify that the certificate is within its validity period and is tied to a trusted root. Finally, you must do revocation checks against each intermediate level, and also check the fingerprint of the certificate against explicit blacklists supported by Mozilla / Apple / Google / Microsoft.
I don’t know about any Ruby libraries that automate the review process for you (in the end I hope to add it to r509 ), but given your more specific use case here, there is some untested code that should point you in the right direction .
require 'r509' require 'net/http' cert = R509::Cert.load_from_file("some_iphone_cert.pem") crl_uri = cert.crl_distribution_points.crl.uris[0] crl = Net::HTTP.get_response(URI(crl_uri))
Unfortunately, due to the sheer size (~ 680 thousand records) of the Apple WWDRCA CRL recall, this check can be rather slow with the current r509 hash model.
If you are interested in going down the OCSP path, I can write how to generate OCSP queries / parse responses in Ruby.
Edit: iPhone developer certificates appear, I don’t have the built-in OCIA AIA, so the only revocation check option would be through the CRL distribution point, as shown above.
Edit2: Oh, why not, let him run an OCSP check in Ruby! For this we need a certificate and its certificate of issue. You cannot use the WWDRCA certificate for this, so just grab it from your favorite website. I use my own website.
require 'net/http' require 'r509' cert = R509::Cert.load_from_file("my_website.pem")
In the above code example, the handling of many possible cases of edges is neglected, so it should only be considered as a starting point. Good luck