NIOSSLPrivateKey

public class NIOSSLPrivateKey
extension NIOSSLPrivateKey: Equatable
extension NIOSSLPrivateKey: Hashable

A reference to an BoringSSL private key object in the form of an EVP_PKEY *.

This thin wrapper class allows us to use ARC to automatically manage the memory associated with this key. That ensures that BoringSSL will not free the underlying buffer until we are done with the key.

This class also provides several convenience constructors that allow users to obtain an in-memory representation of a key from a buffer of bytes or from a file path.

  • Create an NIOSSLPrivateKey from a file at a given path in either PEM or DER format, providing a passphrase callback.

    Declaration

    Swift

    public convenience init(file: String, format: NIOSSLSerializationFormats) throws

    Parameters

    file

    The path to the file to load.

    format

    The format of the key to load, either DER or PEM.

  • Create an NIOSSLPrivateKey from a file at a given path in either PEM or DER format, providing a passphrase callback.

    Declaration

    Swift

    public convenience init<T>(file: String, format: NIOSSLSerializationFormats, passphraseCallback: @escaping NIOSSLPassphraseCallback<T>) throws where T : Collection, T.Element == UInt8

    Parameters

    file

    The path to the file to load.

    format

    The format of the key to load, either DER or PEM.

    passphraseCallback

    A callback to invoke to obtain the passphrase for encrypted keys.

  • Create an NIOSSLPrivateKey from a buffer of bytes in either PEM or DER format.

    Declaration

    Swift

    @available(*, deprecated, renamed: "NIOSSLPrivateKey.init(bytes:format:﹚")
    public convenience init(buffer: [Int8], format: NIOSSLSerializationFormats) throws

    Parameters

    buffer

    The key bytes.

    format

    The format of the key to load, either DER or PEM.

  • Create an NIOSSLPrivateKey from a buffer of bytes in either PEM or DER format.

    Declaration

    Swift

    public convenience init(bytes: [UInt8], format: NIOSSLSerializationFormats) throws

    Parameters

    bytes

    The key bytes.

    format

    The format of the key to load, either DER or PEM.

  • Create an NIOSSLPrivateKey from a buffer of bytes in either PEM or DER format.

    Declaration

    Swift

    @available(*, deprecated, renamed: "NIOSSLPrivateKey.init(bytes:format:passphraseCallback:﹚")
    public convenience init<T>(buffer: [Int8], format: NIOSSLSerializationFormats, passphraseCallback: @escaping NIOSSLPassphraseCallback<T>) throws where T : Collection, T.Element == UInt8

    Parameters

    buffer

    The key bytes.

    format

    The format of the key to load, either DER or PEM.

    passphraseCallback

    Optionally a callback to invoke to obtain the passphrase for encrypted keys. If not provided, or set to nil, the default BoringSSL behaviour will be used, which prints a prompt and requests the passphrase from stdin.

  • Create an NIOSSLPrivateKey from a buffer of bytes in either PEM or DER format.

    Declaration

    Swift

    public convenience init<T>(bytes: [UInt8], format: NIOSSLSerializationFormats, passphraseCallback: @escaping NIOSSLPassphraseCallback<T>) throws where T : Collection, T.Element == UInt8

    Parameters

    bytes

    The key bytes.

    format

    The format of the key to load, either DER or PEM.

    passphraseCallback

    Optionally a callback to invoke to obtain the passphrase for encrypted keys. If not provided, or set to nil, the default BoringSSL behaviour will be used, which prints a prompt and requests the passphrase from stdin.

  • Declaration

    Swift

    public static func == (lhs: NIOSSLPrivateKey, rhs: NIOSSLPrivateKey) -> Bool
  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)