SSLService
public class SSLService : SSLServiceDelegate
SSLService:** SSL Service Plugin for Socket using Apple Secure Transport on macOS
and OpenSSL on Linux
.
-
Used to dispatch reads and writes to protect the SSLContext
Declaration
Swift
public struct SSLReadWriteDispatcher
-
SSL Configuration
See moreDeclaration
Swift
public struct Configuration
-
Verification Callback. Called by the internal
verifyConnection()
function to do any additional connection verification. This property is set after initializing theSSLService
.Declaration
Swift
public var verifyCallback: ((_ service: SSLService) -> (Bool, String?))?
Return Value
Tuple containing a
Bool
to indicate success or failure of the verification and aString?
containing text describing the error if desired. -
If true, skips the internal verification. However, if the
verifyCallback
property is set, the callback will be called regardless of this setting. Default is false. This property is set after initializing theSSLService
.Declaration
Swift
public var skipVerification: Bool
-
SSL Configuration (Read only)
Declaration
Swift
public private(set) var configuration: Configuration { get }
-
True
if setup as server,false
if setup as client.Declaration
Swift
public private(set) var isServer: Bool { get }
-
Read/write dispatcher to serialize these operations…
Declaration
Swift
public private(set) var rwDispatch: SSLService.SSLReadWriteDispatcher { get }
-
SSL Connection
-
SSL Method Note: We use
SSLv23
which causes negotiation of the highest available SSL/TLS version. -
SSL Context
-
List of supported ALPN protocols
-
The negotiated ALPN protocol, if any
-
Socket Pointer containing the socket fd (passed to the
SSLRead
andSSLWrite
callback routines).Declaration
Swift
public private(set) var socketPtr: UnsafeMutablePointer<Int32> { get }
-
SSL Context
Declaration
Swift
public private(set) var context: SSLContext? { get }
-
Initialize an
SSLService
instance.Declaration
Swift
public init?(usingConfiguration config: Configuration) throws
Parameters
config
Configuration to use.
Return Value
SSLService
instance.
-
Initialize
SSLService
Declaration
Swift
public func initialize(asServer: Bool) throws
Parameters
asServer
True
for initializing a server, otherwise a client. -
Deinitialize
SSLService
Declaration
Swift
public func deinitialize()
-
Processing on acceptance from a listening socket
Declaration
Swift
public func onAccept(socket: Socket) throws
Parameters
socket
The connected
Socket
instance. -
Processing on connection to a listening socket
Declaration
Swift
public func onConnect(socket: Socket) throws
Parameters
socket
The connected
Socket
instance. -
Low level writer
Declaration
Swift
public func send(buffer: UnsafeRawPointer, bufSize: Int) throws -> Int
Parameters
buffer
Buffer pointer.
bufSize
Size of the buffer.
-
Low level reader
Declaration
Swift
public func recv(buffer: UnsafeMutableRawPointer, bufSize: Int) throws -> Int
Parameters
buffer
Buffer pointer.
bufSize
Size of the buffer.
Return Value
The number of bytes read. Zero indicates SSL shutdown or in the case of a non-blocking socket, no data available for reading, less than zero indicates error.