Specifies an I/O connection for a specific session.


OSStatus SSLSetConnection(SSLContextRef context, SSLConnectionRef connection);



An SSL session context reference.


An SSL session connection reference. The connection data is opaque to Secure Transport; you can set it to any value that your application can use to uniquely identify the connection in the callback functions SSLReadFunc and SSLWriteFunc.

Return Value

A result code. See Secure Transport Result Codes.


You must establish a connection before creating a secure session. After calling the SSLCreateContext function to create an SSL session context, you call the SSLSetConnection function to specify the connection to which the context applies. You specify a value in the connection parameter that your callback routines can use to identify the connection. This value might be a pointer to a socket (if you are using the Sockets API) or an endpoint (if you are using Open Transport). For example, you might create a socket, start a connection on it, create a context reference, cast the socket to an SSLConnectionRef, and then pass both the context reference and connection reference to the SSLSetConnection function.

Note that the Sockets API is the preferred networking interface for new development.

On the client side, it’s assumed that communication has been established with the desired server on this connection. On the server side, it’s assumed that a connection has been established in response to an incoming client request .

This function must be called prior to the SSLHandshake function; consequently, this function can be called only when no session is active.

See Also

I/O Connections


Retrieves an I/O connection—such as a socket or endpoint—for a specific session.


A pointer to an opaque I/O connection object.