You probably heard about excellent report "APT1: Exposing One of China's Cyber Espionage Units" published by the Mandiant company (you can download it here). Report is great and I recommend it to anyone interested in computer security.

Together with the report Mandiant published SSL certificates used in communication between APT1 malware and it's C2 (command & control) servers in appendix F. However, the published certificates are in text format like this:

Version: 3 (0x2)
Serial Number: 1 (0x1)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=US, ST=Some-State, O=www.virtuallythere.com, OU=new, CN=new
Not Before: Oct 23 03:25:49 2007 GMT
Not After : Oct 22 03:25:49 2008 GMT
Subject: C=US, ST=Some-State, O=www.virtuallythere.com, OU=new, CN=new
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (1024 bit)
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints:
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
X509v3 Authority Key Identifier:
Signature Algorithm: sha1WithRSAEncryption

What I believe is not very "workable" format: I would like to implement a script to check my network for APT1 certificates, but to do it I would need certificate in PEM format or at least fingerprints (sha1, md5) of certificate to automate process of detecting these certificates in my network.

Is there any way to convert certificate in format as above to PEM format or at least a way to calculate sha1 fingerprint for the cert?

I found this, which suggest that such conversion is cubersome and complicated. Do you agree? Does requesting Mandiant to release certificates in other (PEM) format is my best bet here?

1 Answer 1


You cannot, generically, reliably rebuild the base certificate from which such a report was generated (apparently with the OpenSSL command-line tool). For instance, you have the string contents of the Issuer and Subject names, but not the information about how they were encoded.

You could use the signature as a discriminant for the certificates. You won't find a "normal" certificate with the exact same signature value (it is possible to build a fake certificate which contains the same signature, but you have to do it on purpose).

If you know the public key of the certificate which was used to issue this specific certificate, then you could use the public key to do the first steps of the signature verification, yielding the SHA-1 hash of the "To Be Signed" (that's a feature of PKCS#1 RSA signatures: this is an algorithm "with recovery": from the signature and the public key, you can obtain a hash of the data which was signed). With that hash, you could test whether a putative reconstruction of the certificate is correct or not. But this is hard work. If you just want to check whether a given certificate is one of the certificates in the Mandiant report, extract the signature field (e.g. with OpenSSL) and look it up in the lists published by Mandiant.

  • Thanks. One more thing: Does openssl command line tool has option to extract signature field from certificate? I found that modulus can be extracted but I couldn't find any cli switch to extract signature. Thanks in advance.
    – mzet
    Commented Mar 19, 2013 at 8:21
  • You can use openssl x509 -text -noout -in cert.pem to analyze the certificate in cert.pem; the signature is at the end. It is then a matter of finding the second occurrence of "Signature Algorithm:" at the start of a line (after removing leading spaces). If you have the certificate as DER (or convert it to DER), then you could also look at the last bytes: that's the signature, as is (e.g. in your example, the last five bytes of the DER-encoded certificate will be 1d 73 85 4d be).
    – Tom Leek
    Commented Mar 19, 2013 at 12:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .