I have the privilege of handling ~5 SSL CSRs per week, checking their validity before passing them off to our CA for action. I use OpenSSL on an Ubuntu machine to check that they are valid, testing things like the correct OU name, a sensible CN, key size >=2048 bits and so on, as our requests are sometimes incorrect.
The other day I received a renewal request from an IIS7 machine. I can't figure out how to read this at all, using OpenSSL. It is valid, as my CA has accepted it ...
'file(1)' says it is an "RFC1421 Security Certificate Signing Request text", which is what it says for ~50% of the CSRs I have here (the rest are "PEM certificate request").
$ head iis7rcsr
-----BEGIN NEW CERTIFICATE REQUEST-----
MIIQsQYJKoZIhvcNAQcCoIIQojCCEJ4CAQExCzAJBgUrDgMCGgUAMIIJegYJKoZI
hvcNAQcBoIIJawSCCWcwggljMIIIzAIBADCB2zELMAkGA1UEBhMCTloxDTALBgNV
BBEMBDkwNTQxDjAMBgNVBAgMBU90YWdvMRAwDgYDVQQHDAdEdW5lZGluMRwwGgYD
...
...
openssl req
, which reads CSRs (PKCS#10) fails to comprehend it ...
$ openssl req -in iis7rcsr -text
unable to load X509 request
5156:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1316:
5156:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:380:Type=X509_REQ_INFO
5156:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:748:Field=req_info, Type=X509_REQ
5156:error:0906700D:PEM routines:PEM_ASN1_read_bio:ASN1 lib:pem_oth.c:83:
This article from Andreas Klein on the MSDN blogs suggests that IIS7 renewal CSRs are a PKCS#7 container, with a CSR and a signature based on the current certificate ... but I still can't read it.
$ openssl pkcs7 -in iis7rcsr -text
unable to load PKCS7 object
6581:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:650:Expecting: PKCS7
I can use 'openssl base64' to decode the file, and in the resulting binary file I can see strings that look like the CSR, and some CA references that must have come from a signature based on the old certificate. So the idea of container(CSR,signature) sounds plausible.
But I still cannot find a way of reading the CSR that's in there! I have tried a lot of things, I won't list the details here, but here are the high points of variations I've tried : pkcs12 pkcs7 PEM DER req x509 verify ...
I cannot post the CSR itself here unfortunately. Can anyone help me figure out a way of reading/verifying this file?