         }
     }
 
-    /*
     func connectSSL() throws {
-        var context: SSLContextRef = SSLCreateContext(nil, kSSLClientSide, kSSLStreamType)
-        if context == nil {
-            return try? NWErrorUtil.noWithErrorCode(kNWErrorSSLContext)!
-        }
-        var setio: OSStatus = SSLSetIOFuncs(context, NWSSLRead, NWSSLWrite)
-        if setio != errSecSuccess {
-            return try? NWErrorUtil.noWithErrorCode(kNWErrorSSLIOFuncs, reason: setio)!
-        }
-        var setconn: OSStatus? = SSLSetConnection(context, (Int(self.socket) as? SSLConnectionRef))
-        if setconn != errSecSuccess {
-            return try? NWErrorUtil.noWithErrorCode(kNWErrorSSLConnection, reason: setconn)!
-        }
-        var setpeer: OSStatus = SSLSetPeerDomainName(context, self.host.utf8, strlen(self.host.utf8))
-        if setpeer != errSecSuccess {
-            return try? NWErrorUtil.noWithErrorCode(kNWErrorSSLPeerDomainName, reason: setpeer)!
-        }
-        var setcert: OSStatus? = SSLSetCertificate(context, ([self.identity] as? CFArrayRef))
-        if setcert != errSecSuccess {
-            return try? NWErrorUtil.noWithErrorCode(kNWErrorSSLCertificate, reason: setcert)!
+        guard let context = SSLCreateContext(nil, .clientSide, .streamType) else {
+            throw NWError.SSLConnectionCannotBeSet
+        }
+        if SSLSetIOFuncs(context, NWSSLRead, NWSSLWrite) != errSecSuccess {
+            throw NWError.SSLConnectionCannotBeSet
+        }
+        if SSLSetConnection(context, Int(self.socket) as? SSLConnectionRef) != errSecSuccess {
+            throw NWError.SSLConnectionCannotBeSet
+        }
+        if SSLSetPeerDomainName(context, self.host.cString, self.host.length) != errSecSuccess {
+            throw NWError.SSLConnectionCannotBeSet
+        }
+        if SSLSetCertificate(context, [self.identity] as? CFArray) != errSecSuccess {
+            throw NWError.SSLConnectionCannotBeSet
         }
         self.context = context
-        //return true
-    }
-
+    }
+     
+     /*
     func handshakeSSL() throws {
         var status: OSStatus = errSSLWouldBlock
         var i = 0

//  Copyright (c) 2012 noodlewerk. All rights reserved.
//
import Foundation
/** An SSL (TLS) connection to the APNs.

 This class is basically an Objective-C wrapper around `SSLContextRef` and `SSLConnectionRef`, which are part of the native Secure Transport framework. This class provides a generic interface for SSL (TLS) connections, independent of NWPusher.

 */
}

let NWSSL_HANDSHAKE_TRY_COUNT = 1 << 26

//(SSLConnectionRef, UnsafeMutableRawPointer, UnsafeMutablePointer<Int>)
func NWSSLRead(connection: SSLConnectionRef, data: UnsafeMutableRawPointer, length: UnsafeMutablePointer<Int>) -> OSStatus {
    /*var leng: size_t = length
    length = 0
    var read: size_t = 0
    var rcvd: ssize_t = 0
