Implementing a Secure Socket (Windows CE 5.0)
The following procedure describes how to establish a secure socket connection.
To implement a secure socket
Create a socket with the socket function.
Set the socket in secure mode with the setsockopt function. Set level to SOL_SOCKET, optname to SO_SECURE, and optval to a DWORD set to SO_SEC_SSL.
Specify the certificate validation callback function by calling WSAIoctl with the SO_SSL_SET_VALIDATE_CERT_HOOK control code.
To verify the server's identity during the handshake, call WSAIoctl with the SO_SSL_SET_PEERNAME control code.
The server name is verified against the server certificate after a successful SSL handshake. The verification results are then indicated in the certificate validation callback. If the specified server name does not match the one indicated in the certificate chain of the SSL Handshake, SSL_CERT_FLAG_ISSUER_UNKNOWN is set in the dwFlags parameter of SslValidateCertHook.
If you do not perform this step, no verification is performed.
To specify a particular security protocol, call WSAIoctl with the SO_SSL_GET_PROTOCOLS control code to determine the default protocols. Then call WSAIoctl with the SO_SSL_SET_PROTOCOLS control code to select the protocols to be enabled. Otherwise, Windows CE selects the protocol.
Make a connection with the connect function.
The certificate callback function is automatically called. The connection can be completed only if the callback function verifies the acceptability of the certificate by returning SSL_ERR_OKAY.
Transmit and send.
The send and recv functions automatically encode and decode data.
When you are finished, close the socket with the closesocket function.
See Also
Winsock Secure Sockets | WSAIoctl | Secure Socket Control Codes
Send Feedback on this topic to the authors