Certificate
public struct Certificate : Equatable
Certificate for TLS/SSL encrypted connections
A certificate can be loaded from a PKCS12-file or directly as a SecIdentityRef.
-
Initialize a new certificate with the given data protected by the given password. The data has to be in PKCS12 format.
If the certificate cannot be loaded, a TLSError is thrown. For further information, activate the -skdebug flag, which prints further error messages.
Throws
A TLSError indicating that the certificate could not be loaded.
Declaration
Swift
public init(with data:Data, password:String? = nil) throws
Parameters
data
Data object containing the PKCS12 certificate and key
password
Password protecting the the specified PKCS12 certificate. If no password should be used, the password should be nil.
-
Creates a new certificate with the specified SecIdentityRef.
Declaration
Swift
public init(with identity: SecIdentity)
Parameters
identity
Identity containing the certificate and private key to use
-
Initialize a new certificate with the data at the given path protected by the given password. The data has to be in PKCS12 format.
If the certificate cannot be loaded, a TLSError is thrown. For further information, activate the -skdebug flag, which prints further error messages.
Throws
A TLSError indicating that the certificate could not be loaded.
Declaration
Swift
public init(contentsOf filePath: String, password: String? = nil) throws
Parameters
filePath
Path to file containing the PKCS12 certificate and key
password
Password protecting the the specified PKCS12 certificate If no password should be used, the password should be nil.
-
Initialize a new certificate with the data at the given path protected by the given password. The data has to be in PKCS12 format.
If the certificate cannot be loaded, a TLSError is thrown. For further information, activate the -skdebug flag, which prints further error messages.
Throws
A TLSError indicating that the certificate could not be loaded.
Declaration
Swift
public init(contentsOf filePath: String, readingOptions: NSData.ReadingOptions, password: String? = nil) throws
Parameters
filePath
Path to file containing the PKCS12 certificate and key
readingOptions
Options for reading
password
Password protecting the the specified PKCS12 certificate If no password should be used, the password should be nil.