riboseinc / digicert

Ruby bindings for the Digicert Services API
https://www.digicert.com/services/v2/documentation
MIT License
8 stars 10 forks source link

Add interface to retrieve certificate content #108

Closed abunashir closed 7 years ago

abunashir commented 7 years ago

This commit adds an interface to retrieve the certificate contents as hash. Underneath, it downloads the certificate as pem and then it extract all of the subsidiary certificate and then build a hash with certificate, intermediate_certificate & root_certificate

Digicert::CertificateDownloader.fetch_content(certificate_id)

# alternative using certificate instance
#
certificate = Digicert::Certificate.find(certificate_id)
certificate.download_content

Solves #101, cheers!

ronaldtse commented 7 years ago

@abunashir this is awesome. Just a minor detail, the current assumption is that there will be only 3 certificates. However, I have seen a Digicert PEM that has 4 certificates too.

In any case, the certificate is the first one, the root is the last one, and the middle ones are the intermediate.

Thanks!

abunashir commented 7 years ago

@ronaldtse : I just added another commit to fix this and also another key to return the full response as it is.