SslStream.AuthenticateAsServer Method
System.Net.Security
Authenticates the server end of an SSL/TLS connection.
Overloads
- AuthenticateAsServer(X509Certificate serverCertificate)
- AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
- AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, RemoteCertificateValidationCallback userCertificateValidationCallback, bool checkCertificateRevocation)
- AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, CipherSuitesPolicy enabledSslCipherSuites)
- AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, RemoteCertificateValidationCallback userCertificateValidationCallback, SslProtocols enabledSslProtocols, CipherSuitesPolicy enabledSslCipherSuites)
AuthenticateAsServer(X509Certificate serverCertificate)
Parameters
serverCertificate
AnX509Certificatethat contains the server's public and private keys.
Note: This overload uses default values for client certificate requirements, enabled SSL protocols, and certificate revocation checking. For more control, use other overloads.
AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
Parameters
serverCertificate
AnX509Certificatethat contains the server's public and private keys.clientCertificateRequiredtrueto require a client certificate; otherwise,false.enabledSslProtocols
A bitwise combination of theSslProtocolsvalues that specifies the protocols to use for authentication.checkCertificateRevocationtrueto check for certificate revocation; otherwise,false.
AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, RemoteCertificateValidationCallback userCertificateValidationCallback, bool checkCertificateRevocation)
Parameters
serverCertificate
AnX509Certificatethat contains the server's public and private keys.clientCertificateRequiredtrueto require a client certificate; otherwise,false.userCertificateValidationCallback
ARemoteCertificateValidationCallbackdelegate that provides a callback method to validate the remote certificate.checkCertificateRevocationtrueto check for certificate revocation; otherwise,false.
AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, CipherSuitesPolicy enabledSslCipherSuites)
Parameters
serverCertificate
AnX509Certificatethat contains the server's public and private keys.clientCertificateRequiredtrueto require a client certificate; otherwise,false.enabledSslProtocols
A bitwise combination of theSslProtocolsvalues that specifies the protocols to use for authentication.enabledSslCipherSuites
ACipherSuitesPolicyobject that specifies the allowed cipher suites.
AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, RemoteCertificateValidationCallback userCertificateValidationCallback, SslProtocols enabledSslProtocols, CipherSuitesPolicy enabledSslCipherSuites)
Parameters
serverCertificate
AnX509Certificatethat contains the server's public and private keys.clientCertificateRequiredtrueto require a client certificate; otherwise,false.userCertificateValidationCallback
ARemoteCertificateValidationCallbackdelegate that provides a callback method to validate the remote certificate.enabledSslProtocols
A bitwise combination of theSslProtocolsvalues that specifies the protocols to use for authentication.enabledSslCipherSuites
ACipherSuitesPolicyobject that specifies the allowed cipher suites.
Remarks
- The
AuthenticateAsServermethod completes the SSL/TLS handshake. This method must be called before any data is sent or received. - For the server to be able to authenticate itself, a server certificate must be available. If
serverCertificateisnull, anArgumentNullExceptionexception is thrown. - If the server requires a client certificate, set the
clientCertificateRequiredparameter totrue. - The
userCertificateValidationCallbackdelegate allows you to customize how client certificates are validated. - The
enabledSslProtocolsparameter allows you to specify which SSL/TLS protocols are allowed. It is recommended to use the most secure available protocols. - The
checkCertificateRevocationparameter determines whether to check for certificate revocation. Enabling this check enhances security. - The
enabledSslCipherSuitesparameter allows fine-grained control over which cipher suites are permitted for the connection.
Requirements
- Namespace:
System.Net.Security - Assembly:
System.Net.Security.dll