Skip to content
This repository has been archived by the owner on May 15, 2018. It is now read-only.

Added ability to import certificates of other types than PKCS12/PFX #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

allansson
Copy link

The Import-PfxCertificate only allows importing PKCS12-encoded certificates (often with its private key). Windows however allows certificates to be exported in several formats: PKCS12, PKCS7 and X509 (DER and Base64 encoded).

I have added an additional parameter Format to the resource to allow the user to specify which format the certificate is in, and some additional logic to use the Import-Certificate method for all formats except PKCS12. Available formats are PKCS12, PKCS7 and X509. The resource will default to the PKCS12 format for backwards compatibility.

I first considered basing the logic solely on the file extension of the FilePath, but reconsidered since in my experience there are a lot of variations on certificate file extensions: .cer, .cert, .crt, .pfx, .p12.

Certificates can be exported in Windows using 4 different formats:
PKCS12, PKCS7, DER encoded X509 and Base64 encoded X509. The
Import-PfxCertificate only supports PKCS12/PFX, for all other types it
is necessary to use the Import-Certificate method instead.

I added an additional parameter to the CertificateStore specifying the
format of the certificate, allowing the user to choose from PKCS12
(default), PKCS7 and X509 (both DER and Base64), and implemented a check
to determine which method to use while importing.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant