Interface KeyPairResourceWriter<OPTIONS extends PrivateKeyEncryptionContext>

    • Method Detail

      • writePrivateKey

        void writePrivateKey​(KeyPair key,
                             String comment,
                             OPTIONS options,
                             OutputStream out)
                      throws IOException,
                             GeneralSecurityException
        Writes a serialization of a private key from a given KeyPair to a given OutputStream.
        Parameters:
        key - to write the private key of
        comment - to write with the private key
        options - for writing the key; may be null if no encryption is wanted. The caller is responsible for clearing the options when no longer needed. If the passphrase obtained from the context is null or an empty/blank string (length zero or containing only whitespace), the key is written unencrypted.
        out - The OutputStream to write to - recommend using a SecureByteArrayOutputStream in order to reduce sensitive data exposure in memory
        Throws:
        GeneralSecurityException - if the key is inconsistent or unknown, or the encryption specified cannot be applied
        IOException - if the key cannot be written