Package ghidra.net

Class ApplicationKeyManagerUtils


  • public class ApplicationKeyManagerUtils
    extends java.lang.Object
    ApplicationKeyManagerUtils provides public methods for utilizing the application PKI key management, including access to trusted issuers (i.e., CA certificates), token signing and validation, and the ability to generate keystores for testing or when a self-signed certificate will suffice.

Method Detail

  • exportX509Certificates NEW

    public static void exportX509Certificates​(java.security.cert.Certificate[] certificates,
                                              java.io.File outFile)
                                       throws java.io.IOException,
                                              java.security.cert.CertificateEncodingException
    Export X.509 certificates to the specified outFile.
    Parameters:
    certificates - certificates to be stored
    outFile - output file
    Throws:
    java.io.IOException - if error occurs writing to outFile
    java.security.cert.CertificateEncodingException - if error occurs while encoding certificate data
  • createKeyStore NEW

    public static final java.security.KeyStore createKeyStore​(java.lang.String alias,
                                                              java.lang.String dn,
                                                              int durationDays,
                                                              java.security.KeyStore.PrivateKeyEntry caEntry,
                                                              java.io.File keyFile,
                                                              java.lang.String keystoreType,
                                                              char[] protectedPassphrase)
                                                       throws java.security.KeyStoreException
    Generate a new X509Certificate with RSA KeyPair and create/update a KeyStore optionally backed by a keyFile.
    Parameters:
    alias - entry alias with keystore
    dn - distinguished name (e.g., "CN=Ghidra Test, O=Ghidra, OU=Test, C=US" )
    durationDays - number of days which generated certificate should remain valid
    caEntry - optional CA private key entry. If null, a self-signed CA certificate will be generated.
    keyFile - optional file to load/store resulting KeyStore (may be null)
    keystoreType - support keystore type (e.g., "JKS", "PKCS12")
    protectedPassphrase - key and keystore protection password
    Returns:
    keystore containing newly generated certification with key pair
    Throws:
    java.security.KeyStoreException - if error occurs while updating keystore
  • createKeyEntry NEW

    public static final java.security.KeyStore.PrivateKeyEntry createKeyEntry​(java.lang.String alias,
                                                                              java.lang.String dn,
                                                                              int durationDays,
                                                                              java.security.KeyStore.PrivateKeyEntry caEntry,
                                                                              java.io.File keyFile,
                                                                              java.lang.String keystoreType,
                                                                              char[] protectedPassphrase)
                                                                       throws java.security.KeyStoreException
    Generate a new X509Certificate with RSA KeyPair and create/update a KeyStore optionally backed by a keyFile.
    Parameters:
    alias - entry alias with keystore
    dn - distinguished name (e.g., "CN=Ghidra Test, O=Ghidra, OU=Test, C=US" )
    durationDays - number of days which generated certificate should remain valid
    caEntry - optional CA private key entry. If null, a self-signed CA certificate will be generated.
    keyFile - optional file to load/store resulting KeyStore (may be null)
    keystoreType - support keystore type (e.g., "JKS", "PKCS12")
    protectedPassphrase - key and keystore protection password
    Returns:
    newly generated keystore entry with key pair
    Throws:
    java.security.KeyStoreException - if error occurs while updating keystore