0001    // SSLContext.swift
0002    //
0003    // The MIT License (MIT)
0004    //
0005    // Copyright (c) 2015 Zewo
0006    //
0007    // Permission is hereby granted, free of charge, to any person obtaining a copy
0008    // of this software and associated documentation files (the "Software"), to deal
0009    // in the Software without restriction, including without limitation the rights
0010    // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0011    // copies of the Software, and to permit persons to whom the Software is
0012    // furnished to do so, subject to the following conditions:
0013    //
0014    // The above copyright notice and this permission notice shall be included in all
0015    // copies or substantial portions of the Software.
0016    //
0017    // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0018    // IMPLIED, INCLUDINbG BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0019    // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0020    // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0021    // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0022    // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0023    // SOFTWARE.
0024    
0025    import COpenSSL
0026    
0027    public class Context
ClientContext.swift:27
public final class SSLClientContext: Context {
ClientContext.swift:34
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:39
                throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:45
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:51
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:57
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:61
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:27
public final class SSLServerContext: Context {
ServerContext.swift:33
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:38
                throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:43
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:47
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:51
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
Session.swift:50
	public init(context: Context) throws {
{ 0028 0029 public enum Error
ClientContext.swift:34
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:39
                throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:45
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:51
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:57
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:61
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
Context.swift:41
            throw Error.Context(description: lastSSLErrorDescription)
Context.swift:47
            throw Error.Context(description: lastSSLErrorDescription)
Context.swift:53
            throw Error.Context(description: lastSSLErrorDescription)
Context.swift:59
            throw Error.Context(description: lastSSLErrorDescription)
Context.swift:65
            throw Error.Context(description: lastSSLErrorDescription)
ServerContext.swift:33
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:38
                throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:43
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:47
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:51
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
: ErrorType { 0030 case Context
Context.swift:41
            throw Error.Context(description: lastSSLErrorDescription)
Context.swift:47
            throw Error.Context(description: lastSSLErrorDescription)
Context.swift:53
            throw Error.Context(description: lastSSLErrorDescription)
Context.swift:59
            throw Error.Context(description: lastSSLErrorDescription)
Context.swift:65
            throw Error.Context(description: lastSSLErrorDescription)
(description: String) 0031 case Certificate
ClientContext.swift:34
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:39
                throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:45
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:51
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:57
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ClientContext.swift:61
				throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:33
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:38
                throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:43
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:47
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
ServerContext.swift:51
            throw Context.Error.Certificate(description: lastSSLErrorDescription)
(description: String) 0032 } 0033 0034 var context
ClientContext.swift:31
        SSL_CTX_set_verify(context, SSL_VERIFY_PEER, nil)
ClientContext.swift:33
        if SSL_CTX_set_default_verify_paths(context) != 1 {
ClientContext.swift:38
            if SSL_CTX_load_verify_locations(context, verifyBundle, nil) != 1 {
ClientContext.swift:44
			if SSL_CTX_use_certificate_chain_file(context, certificateChain) != 1 {
ClientContext.swift:50
			if SSL_CTX_use_certificate_file(context, certificate, SSL_FILETYPE_PEM) != 1 {
ClientContext.swift:56
			if SSL_CTX_use_PrivateKey_file(context, privateKey, SSL_FILETYPE_PEM) != 1 {
ClientContext.swift:60
			if SSL_CTX_check_private_key(context) != 1 {
Context.swift:38
        context = SSL_CTX_new(getMethod(method, type: type))
Context.swift:40
        if context == nil {
Context.swift:46
        if SSL_CTX_use_certificate(context, certificate.certificate) != 1 {
Context.swift:52
        if SSL_CTX_use_PrivateKey(context, privateKey.key) != 1 {
Context.swift:58
        if SSL_CTX_set_cipher_list(context, cipherSuites) != 1 {
Context.swift:64
        if SSL_CTX_set_tlsext_use_srtp(context, srtpProfiles) != 1 {
ServerContext.swift:30
        SSL_CTX_set_verify(context, SSL_VERIFY_NONE, nil)
ServerContext.swift:32
        if SSL_CTX_ctrl(context, SSL_CTRL_SET_ECDH_AUTO, 1, nil) != 1 {
ServerContext.swift:37
            if SSL_CTX_use_certificate_chain_file(context, certificateChain) != 1 {
ServerContext.swift:42
        if SSL_CTX_use_certificate_file(context, certificate, SSL_FILETYPE_PEM) != 1 {
ServerContext.swift:46
        if SSL_CTX_use_PrivateKey_file(context, privateKey, SSL_FILETYPE_PEM) != 1 {
ServerContext.swift:50
        if SSL_CTX_check_private_key(context) != 1 {
Session.swift:53
        ssl = SSL_new(context.context)
: UnsafeMutablePointer<SSL_CTX> 0035 0036 public init
ClientContext.swift:29
		try super.init(method: .SSLv23, type: .Client)
ServerContext.swift:29
		try super.init(method: .SSLv23, type: .Server)
(method: SSLMethod = .SSLv23, type: SSLMethodType = .Unspecified) throws { 0037 OpenSSL.initialize() 0038 context = SSL_CTX_new(getMethod(method, type: type)) 0039 0040 if context == nil { 0041 throw Error.Context(description: lastSSLErrorDescription) 0042 } 0043 } 0044 0045 public func useCertificate(certificate: Certificate) throws { 0046 if SSL_CTX_use_certificate(context, certificate.certificate) != 1 { 0047 throw Error.Context(description: lastSSLErrorDescription) 0048 } 0049 } 0050 0051 public func usePrivateKey(privateKey: Key) throws { 0052 if SSL_CTX_use_PrivateKey(context, privateKey.key) != 1 { 0053 throw Error.Context(description: lastSSLErrorDescription) 0054 } 0055 } 0056 0057 public func setCipherSuites(cipherSuites: String) throws { 0058 if SSL_CTX_set_cipher_list(context, cipherSuites) != 1 { 0059 throw Error.Context(description: lastSSLErrorDescription) 0060 } 0061 } 0062 0063 public func setSrtpProfiles(srtpProfiles: String) throws { 0064 if SSL_CTX_set_tlsext_use_srtp(context, srtpProfiles) != 1 { 0065 throw Error.Context(description: lastSSLErrorDescription) 0066 } 0067 } 0068 0069 } 0070