NIOSSLCertificate

public class NIOSSLCertificate
extension NIOSSLCertificate: Equatable
extension NIOSSLCertificate: Hashable
extension NIOSSLCertificate: CustomStringConvertible

A reference to a BoringSSL Certificate object (X509 *).

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

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

  • Undocumented

    Declaration

    Swift

    public var serialNumber: [UInt8] { get }
  • Create a NIOSSLCertificate from a file at a given path in either PEM or DER format.

    Note that this method will only ever load the first certificate from a given file.

    Declaration

    Swift

    public convenience init(file: String, format: NIOSSLSerializationFormats) throws
  • Create a NIOSSLCertificate from a buffer of bytes in either PEM or DER format.

    Declaration

    Swift

    @available(*, deprecated, renamed: "NIOSSLCertificate.init(bytes:format:﹚")
    public convenience init(buffer: [Int8], format: NIOSSLSerializationFormats) throws
  • Create a NIOSSLCertificate from a buffer of bytes in either PEM or DER format.

    Declaration

    Swift

    public convenience init(bytes: [UInt8], format: NIOSSLSerializationFormats) throws
  • Obtain the public key for this NIOSSLCertificate.

    Throws

    If an error is encountered extracting the key.

    Declaration

    Swift

    public func extractPublicKey() throws -> NIOSSLPublicKey

    Return Value

    This certificate’s NIOSSLPublicKey.

  • Extracts the bytes of this certificate in DER format.

    Throws

    If an error occurred while serializing the certificate.

    Declaration

    Swift

    public func toDERBytes() throws -> [UInt8]

    Return Value

    The DER-encoded bytes for this certificate.

  • Create an array of NIOSSLCertificates from a buffer of bytes in PEM format.

    Throws

    If an error is encountered while reading certificates.

    Declaration

    Swift

    @available(*, deprecated, renamed: "NIOSSLCertificate.fromPEMBytes(_:﹚")
    public class func fromPEMBuffer(_ buffer: [Int8]) throws -> [NIOSSLCertificate]

    Parameters

    buffer

    The PEM buffer to read certificates from.

  • Create an array of NIOSSLCertificates from a buffer of bytes in PEM format.

    Throws

    If an error is encountered while reading certificates.

    Declaration

    Swift

    public class func fromPEMBytes(_ bytes: [UInt8]) throws -> [NIOSSLCertificate]

    Parameters

    bytes

    The PEM buffer to read certificates from.

  • Create an array of NIOSSLCertificates from a file at a given path in PEM format.

    Throws

    If an error is encountered while reading certificates.

    Declaration

    Swift

    public class func fromPEMFile(_ path: String) throws -> [NIOSSLCertificate]

    Parameters

    file

    The PEM file to read certificates from.

  • Declaration

    Swift

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

    Swift

    public func hash(into hasher: inout Hasher)
  • Declaration

    Swift

    public var description: String { get }