SSLConfig
public struct SSLConfig
A struct that allows you to configure your SSL using a CA certificate file (Linux), a CA certificate directory (Linux) or a certificate chain file (MacOS).
-
Initialize an
SSLService.Configurationinstance using a CA certificate file. -
Initialize an
SSLService.Configurationinstance using a CA certificate directory.Note:
caCertificateDirPath- all certificates in the specified directory must be hashed using the OpenSSL Certificate Tool.
-
Initialize an
SSLService.Configurationinstance 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.
For testing purposes you will most likely want to create and use some self-signed certificates. Follow the instructions in our Enabling SSL/TLS On Your Kitura Server tutorial.
Usage Example:
This example initializes an
SSLConfiginstance and then associates this SSL configuration with the Kitura HTTP server registration.let mySSLConfig = SSLConfig(withChainFilePath: "/tmp/Creds/Self-Signed/cert.pfx", withPassword: "password", usingSelfSignedCerts: true) Kitura.addHTTPServer(onPort: 8080, with: router, withSSL: mySSLConfig)Declaration
Swift
public init(withChainFilePath chainFilePath: String? = nil, withPassword password: String? = nil, usingSelfSignedCerts selfSigned: Bool = true, cipherSuite: String? = nil)Parameters
chainFilePathPath to the certificate chain file (optional). (See note above)
passwordExport password for the chain file (optional). This is required if using a certificate chain file.
selfSignedTrue if certs are self-signed, false otherwise. Defaults to true.
cipherSuiteUnused.
Return Value
New
SSLConfiginstance.
View on GitHub
SSLConfig Structure Reference