|
INT WINAPI InetEnableSecurity( |
|
SOCKET hSocket, |
|
|
DWORD dwOptions, |
|
|
LPSECURITYCREDENTIALS lpCredentials |
|
); |
The InetEnableSecurity function enables a secure session
with the remote host.
Parameters
- hSocket
- The socket handle.
- dwOptions
- An unsigned integer value that specifies additional security
options. It may have a value of zero or one of the following
options:
Constant |
Description |
INET_SECURE_CLIENT |
The certificate specified by the lpCredentials
parameter will be used as a client certificate, and the
application will begin to negotiate the secure session as a
client by initiating the handshake with the server. The
certificate that is used must be a valid client certificate with
a private key associated with it. If the lpCredentials
parameter is NULL, then a secure client session will be
initiated without a client certificate. |
INET_SECURE_SERVER |
The certificate specified by the lpCredentials
parameter will be used as a server certificate, and the
application will wait for the remote host to initiate the
handshake that establishes the parameters of the secure session.
The certificate that is used must be a valid server certificate
and have a private key associated with it. The lpCredentials
parameter cannot be NULL if this option is specified. |
- lpCredentials
- Pointer to a SECURITYCREDENTIALS structure. This parameter
may be NULL, in which case no client credentials will be provided. If client credentials are required, the fields
dwSize, lpszCertStore, and lpszCertName must
be defined, while other fields may be left undefined. Set
dwSize to the size of the SECURITYCREDENTIALS
structure.
Return Value
If the function succeeds, the return value is zero. If the
function fails, the return value is INET_ERROR. To get extended error
information, call InetGetLastError.
Remarks
The InetEnableSecurity function enables a secure
communications session with the remote host, automatically
negotiating the encryption algorithm and validating the certificate.
This function is useful if the application needs to establish a
standard connection to the remote host and then negotiate a
secure connection at a later point. If the function succeeds, all
subsequent calls to InetRead and InetWrite to receive
and send data will be encrypted.
If the dwOptions parameter has a value of zero and the
socket was created using InetConnect or related functions
to establish a client connection, then InetEnableSecurity
will initiate the handshake with the remote host to establish a
secure session. If the InetAccept or related functions were
used to accept a connection from a client, then the function will
block and wait for the client to initiate the handshake.
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header: Include cswsock10.h
Import Library: cswskv10.lib
See Also
InetCreateSecurityCredentials,
InetDeleteSecurityCredentials,
InetDisableSecurity
|
|