Back to Kitura

SSLConfig

docs/docsets/Kitura.docset/Contents/Resources/Documents/Structs/SSLConfig.html

3.0.12.8 KB
Original Source

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).

For Linux

`

                init(withCACertificateFilePath:usingCertificateFile:withKeyFile:usingSelfSignedCerts:cipherSuite:)
                `

Initialize an SSLService.Configuration instance using a CA certificate file.

`

                init(withCACertificateDirectory:usingCertificateFile:withKeyFile:usingSelfSignedCerts:cipherSuite:)
                `

Initialize an SSLService.Configuration instance using a CA certificate directory.

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

For MacOS

`

                init(withChainFilePath:withPassword:usingSelfSignedCerts:cipherSuite:)
                `

Initialize an SSLService.Configuration instance 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 SSLConfig instance 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

| chainFilePath |

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

| | password |

Export password for the chain file (optional). This is required if using a certificate chain file.

| | selfSigned |

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

| | cipherSuite |

Unused.

|

Return Value

New SSLConfig instance.