Configuration

public struct Configuration

SSL Configuration

Properties

  • File name of CA certificate to be used.

    Declaration

    Swift

    public private(set) var caCertificateFilePath: String? { get }
  • Path to directory containing hashed CA’s to be used. Note: caCertificateDirPath - All certificates in the specified directory must be hashed.

    Declaration

    Swift

    public private(set) var caCertificateDirPath: String? { get }
  • Path to the certificate file to be used.

    Declaration

    Swift

    public private(set) var certificateFilePath: String? { get }
  • Path to the key file to be used.

    Declaration

    Swift

    public private(set) var keyFilePath: String? { get }
  • Path to the certificate chain file (optional).

    Declaration

    Swift

    public private(set) var certificateChainFilePath: String? { get }
  • Path to PEM formatted certificate string.

    Declaration

    Swift

    public private(set) var certificateString: String? { get }
  • True if server is using self-signed certificates.

    Declaration

    Swift

    public private(set) var certsAreSelfSigned: Bool { get }
  • True if isServer == false and the client accepts self-signed certificates. Defaults to false, be careful to not leave as true in production

    Declaration

    Swift

    public private(set) var clientAllowsSelfSignedCertificates: Bool { get }
  • Cipher suites to use. Defaults to DEFAULT:!DH

  • Undocumented

    Declaration

    Swift

    public var cipherSuite: String
  • True to use default cipher list, false otherwise.

    Declaration

    Swift

    public var useDefaultCiphers: Bool
  • Password (if needed) typically used for PKCS12 files.

    Declaration

    Swift

    public var password: String?
  • True if no backing certificates provided (Readonly).

    Declaration

    Swift

    public private(set) var noBackingCertificates: Bool { get }
  • For clients that allow self-signed server certificates, verify against ones provided locally.

    Declaration

    Swift

    public private(set) var embeddedServerCertPaths: [URL]? { get }

Lifecycle

  • Initialize a configuration with no backing certificates.

    Declaration

    Swift

    public init(withCipherSuite cipherSuite: String? = nil, clientAllowsSelfSignedCertificates: Bool = true, embeddedServerCertPaths: [URL]? = nil)

    Parameters

    cipherSuite

    Optional String containing the cipher suite to use.

    clientAllowsSelfSignedCertificates

    true to accept self-signed certificates from a server. false otherwise. Note: This parameter is only used when SSLService is used with a client socket.

    • embeddedServerCertPath: when client allows self-signed certificates from a server, verify to server certificate against one of the locally embedded certificates. Pass nil to skip the check. Note: This parameter is only used when SSLService is used with a client socket. Note: This parameter is only available on Apple platforms Note: This feature unavailable (parameter ignored) on MacOS versions less than 10.14, iOS < 12.0

    embeddedServerCertPath

    when client allows self-signed certificates from a server, verify to server certificate against one of the locally embedded certificates. Pass nil to skip the check. Note: This parameter is only used when SSLService is used with a client socket. Note: This parameter is only available on Apple platforms Note: This feature unavailable (parameter ignored) on MacOS versions less than 10.14, iOS < 12.0

    Return Value

    New Configuration instance.

  • Initialize a configuration using a CA Certificate file.

    Warning

    This API is not supported when running on Apple platforms.

    Declaration

    Swift

    public init(withCACertificateFilePath caCertificateFilePath: String?, usingCertificateFile certificateFilePath: String?, withKeyFile keyFilePath: String? = nil, usingSelfSignedCerts selfSigned: Bool = true, cipherSuite: String? = nil)

    Parameters

    caCertificateFilePath

    Path to the PEM formatted CA certificate file.

    certificateFilePath

    Path to the PEM formatted certificate file.

    keyFilePath

    Path to the PEM formatted key file. If nil, certificateFilePath will be used.

    selfSigned

    True if certs are self-signed, false otherwise. Defaults to true.

    cipherSuite

    Optional String containing the cipher suite to use.

    Return Value

    New Configuration instance.

  • Initialize a configuration using a CA Certificate directory.

    Warning

    This API is not supported when running on Apple platforms.

    Note: caCertificateDirPath - All certificates in the specified directory must be hashed using the OpenSSL Certificate Tool.

    Declaration

    Swift

    public init(withCACertificateDirectory caCertificateDirPath: String?, usingCertificateFile certificateFilePath: String?, withKeyFile keyFilePath: String? = nil, usingSelfSignedCerts selfSigned: Bool = true, cipherSuite: String? = nil)

    Parameters

    caCertificateDirPath

    Path to a directory containing CA certificates. (see note above)

    certificateFilePath

    Path to the PEM formatted certificate file. If nil, certificateFilePath will be used.

    keyFilePath

    Path to the PEM formatted key file (optional). If nil, certificateFilePath is used.

    selfSigned

    True if certs are self-signed, false otherwise. Defaults to true.

    cipherSuite

    Optional String containing the cipher suite to use.

    Return Value

    New Configuration instance.

  • Initialize a configuration using a Certificate Chain File.

    Note: If using a certificate chain file, the certificates must be in PEM format and must be sorted starting with the subject’s certificate (actual client or server certificate), followed by intermediate CA certificates if applicable, and ending at the highest level (root) CA.

    Declaration

    Swift

    public init(withChainFilePath chainFilePath: String?, withPassword password: String? = nil, usingSelfSignedCerts selfSigned: Bool = true, clientAllowsSelfSignedCertificates: Bool = false, cipherSuite: String? = nil)

    Parameters

    chainFilePath

    Path to the certificate chain file (optional). (see note above)

    password

    Password for the chain file (optional).

    selfSigned

    True if certs are self-signed, false otherwise. Defaults to true.

    • clientAllowsSelfSignedCertificates: True if, as a client, connections to self-signed servers are allowed

    clientAllowsSelfSignedCertificates

    True if, as a client, connections to self-signed servers are allowed

    cipherSuite

    Optional String containing the cipher suite to use.

    Return Value

    New Configuration instance.

  • Initialize a configuration using a PEM formatted certificate in String form.