Migrating Microsoft CA to EJBCA

The following provides information on migrating a Microsoft CA to EJBCA using the same generic methods to import CA keys and certificate, and import all issued user certificates. After such a complete migration the old CA can be decommissioned. Ensure to keep audit logs in order to enable a full audit trail over the CAs complete lifetime.

Note that EJBCA and MS commands may have changed as new versions have been released.

Export MS CA Key and Import to EJBCA

To export the MS CA key and import it into EJBCA, use the built-in functionality to back up an MS CA. For more information, see the Microsoft documentation on How to move a certification authority to another server.

This gives a PKCS#12 that can be imported to EJBCA.

  • Start a new "mmc" and add the "Certificate Authority" snap-in. Right-click the CA to export > All tasks > Back up CA.
  • Follow the wizard and select Private key and CA certificate, location for storing the p12-file, and a password.
  • Copy the p12-file to the EJBCA machine.
  • Run: $EJBCA_HOME/bin/ejbca.sh ca importca "MS CA v1" /path/mscakey.p12

The CA should now appear in the EJBCA Admin GUI.

Import Existing Certificates to EJBCA

To import existing certificates into EJBCA, you can either import the certificates one at the time if you only have a few certificates or you can choose to import the entire certificate database.

Import Certificates One at the Time

Importing certificates one at the time is suitable if you have a few certificates.

  • Certificates can be exported from the CA-snap-in by opening each certificate and clicking "copy to file..".
  • Convert the certificate to PEM format with openssl: openssl x509 -in certificate.crt -inform DER -out certificate.pem -outform PEM
  • Import to EJBCA with: $EJBCA_HOME/bin/ejbca.sh ca importcert username password "MS CA v1" status certificate.pem EndEntityProfile CertProfile

Import Entire Certificate Database

The entire certificate database is stored in \window\system32\CertLog\CA-name.edb.

The Microsoft server provided Certutil.exe can be used to dump the different posts from the database and the following lists names of possible columns to dump:

certutil -schema 

To dump all certificates with their UPN, TemplateName, Disposition (Issued, Revoked), and the PEM-encoded certificate, run the following:

 certutil -view -restrict "GeneralFlags>0" /out "UPN,CertificateTemplate,Disposition,RawCertificate" > certdump.txt 

After exporting the data with certutil, import it to EJBCA using the script ejbca.sh:

./ejbca.sh ca importcertsms --help

Issue Certificates for SmartCard Logon, DCs, EFS etc