Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Perform SSL handshake
  • Loading branch information
viktorasl committed Aug 2, 2019
commit 756716db25736f548d3a14808d8534953c1f1f33
2 changes: 1 addition & 1 deletion XCode/Sources/Socket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ open class Socket: Hashable, Equatable {
#if !os(Linux)
public func startTlsSession(with certificate: CFArray) throws {
tls = try TlsSession(fd: socketFileDescriptor, certificate: certificate)
// TODO: perform handshake
try tls?.handshake()
}
#endif

Expand Down
8 changes: 8 additions & 0 deletions XCode/Sources/TlsSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ open class TlsSession {
SSLClose(context)
fdPtr.deallocate()
}

open func handshake() throws {
var status: OSStatus = -1
repeat {
status = SSLHandshake(context)
} while status == errSSLWouldBlock
try ensureNoErr(status)
}
}

private func sslWrite(connection: SSLConnectionRef, data: UnsafeRawPointer, dataLength: UnsafeMutablePointer<Int>) -> OSStatus {
Expand Down