public override uint EnableSsl(uint options) { long scopeID = SqlClientEventSource.Log.TrySNIScopeEnterEvent("<sc.SNI.SNINpHandle.EnableSsl |SNI|SCOPE>"); try { _validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0; try { _sslStream.AuthenticateAsClient(_targetServer); _sslOverTdsStream.FinishHandshake(); } catch (AuthenticationException aue) { SqlClientEventSource.Log.TrySNITraceEvent("<sc.SNI.SNINpHandle.EnableSsl |SNI|ERR> AuthenticationException message = {0}.", aue.Message); return(SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, aue)); } catch (InvalidOperationException ioe) { SqlClientEventSource.Log.TrySNITraceEvent("<sc.SNI.SNINpHandle.EnableSsl |SNI|ERR>InvalidOperationException message = {0}.", ioe.Message); return(SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, ioe)); } _stream = _sslStream; return(TdsEnums.SNI_SUCCESS); } finally { SqlClientEventSource.Log.TrySNIScopeLeaveEvent(scopeID); } }
public override uint EnableSsl(uint options) { long scopeID = SqlClientEventSource.Log.TrySNIScopeEnterEvent(s_className); try { _validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0; try { _sslStream.AuthenticateAsClient(_targetServer); _sslOverTdsStream.FinishHandshake(); } catch (AuthenticationException aue) { SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.ERR, "Connection Id {0}, AuthenticationException message = {1}.", args0: ConnectionId, args1: aue?.Message); return(SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, aue)); } catch (InvalidOperationException ioe) { SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.ERR, "Connection Id {0}, InvalidOperationException message = {1}.", args0: ConnectionId, args1: ioe?.Message); return(SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, ioe)); } _stream = _sslStream; return(TdsEnums.SNI_SUCCESS); } finally { SqlClientEventSource.Log.TrySNIScopeLeaveEvent(scopeID); } }
/// <summary> /// Enable SSL /// </summary> public override uint EnableSsl(uint options) { using (TrySNIEventScope.Create(nameof(SNIHandle))) { _validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0; try { _sslStream.AuthenticateAsClient(_targetServer, null, SupportedProtocols, false); _sslOverTdsStream.FinishHandshake(); } catch (AuthenticationException aue) { SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNITCPHandle), EventType.ERR, "Connection Id {0}, Authentication exception occurred: {1}", args0: _connectionId, args1: aue?.Message); return(ReportTcpSNIError(aue, SNIError.CertificateValidationErrorCode)); } catch (InvalidOperationException ioe) { SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNITCPHandle), EventType.ERR, "Connection Id {0}, Invalid Operation Exception occurred: {1}", args0: _connectionId, args1: ioe?.Message); return(ReportTcpSNIError(ioe)); } _stream = _sslStream; SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNITCPHandle), EventType.INFO, "Connection Id {0}, SSL enabled successfully.", args0: _connectionId); return(TdsEnums.SNI_SUCCESS); } }
/// <summary> /// Enable SSL /// </summary> #if NETSTANDARD public override uint EnableSsl(uint options) { _validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0; try { _sslStream.AuthenticateAsClient(_serverNameIndication); if (_sslOverTdsStream != null) { _sslOverTdsStream.FinishHandshake(); } } catch (AuthenticationException aue) { return(ReportTcpSNIError(aue)); } catch (InvalidOperationException ioe) { return(ReportTcpSNIError(ioe)); } _stream = _sslStream; return(TdsEnums.SNI_SUCCESS); }
public override uint EnableSsl(uint options) { _validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0; try { _sslStream.AuthenticateAsClientAsync(_targetServer).GetAwaiter().GetResult(); _sslOverTdsStream.FinishHandshake(); } catch (AuthenticationException aue) { return(SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, aue)); } catch (InvalidOperationException ioe) { return(SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, ioe)); } _stream = _sslStream; return(TdsEnums.SNI_SUCCESS); }
/// <summary> /// Enable SSL /// </summary> public override uint EnableSsl(uint options) { _validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0; try { _sslStream.AuthenticateAsClient(_targetServer, null, SslProtocols.Tls, false); _sslOverTdsStream.FinishHandshake(); } catch (AuthenticationException aue) { return(ReportTcpSNIError(aue)); } catch (InvalidOperationException ioe) { return(ReportTcpSNIError(ioe)); } _stream = _sslStream; return(TdsEnums.SNI_SUCCESS); }
public override uint EnableSsl(uint options) { using (TrySNIEventScope.Create(nameof(SNINpHandle))) { _validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0; try { _sslStream.AuthenticateAsClient(_targetServer, null, SupportedProtocols, false); _sslOverTdsStream.FinishHandshake(); } catch (AuthenticationException aue) { SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNINpHandle), EventType.ERR, "Connection Id {0}, AuthenticationException message = {1}.", args0: ConnectionId, args1: aue?.Message); return(SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, aue)); } catch (InvalidOperationException ioe) { SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNINpHandle), EventType.ERR, "Connection Id {0}, InvalidOperationException message = {1}.", args0: ConnectionId, args1: ioe?.Message); return(SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, ioe)); } _stream = _sslStream; return(TdsEnums.SNI_SUCCESS); } }
/// <summary> /// Enable SSL /// </summary> public override uint EnableSsl(uint options) { _validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0; try { _sslStream.AuthenticateAsClient(_targetServer); _sslOverTdsStream.FinishHandshake(); } catch (AuthenticationException aue) { SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.ERR, "Connection Id {0}, Authentication exception occurred: {1}", args0: _connectionId, args1: aue?.Message); return(ReportTcpSNIError(aue)); } catch (InvalidOperationException ioe) { SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.ERR, "Connection Id {0}, Invalid Operation Exception occurred: {1}", args0: _connectionId, args1: ioe?.Message); return(ReportTcpSNIError(ioe)); } _stream = _sslStream; SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.INFO, "Connection Id {0}, SSL enabled successfully.", args0: _connectionId); return(TdsEnums.SNI_SUCCESS); }