Example #1
0
        /// <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)
            {
                return(ReportTcpSNIError(aue));
            }
            catch (InvalidOperationException ioe)
            {
                return(ReportTcpSNIError(ioe));
            }

            _stream = _sslStream;
            return(TdsEnums.SNI_SUCCESS);
        }
Example #2
0
        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);
        }
Example #3
0
        /// <summary>
        /// Enable SSL
        /// </summary>
        public sealed override SNIError EnableSsl(uint options)
        {
            _validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0;

            try
            {
                _sslStream.AuthenticateAsClientAsync(_targetServer).GetAwaiter().GetResult();
                _sslOverTdsStream.FinishHandshake();
            }
            catch (AuthenticationException aue)
            {
                return(new SNIError(ProviderNumber, 0, aue));
            }
            catch (InvalidOperationException ioe)
            {
                return(new SNIError(ProviderNumber, 0, ioe));
            }

            _stream = _sslStream;
            return(null);
        }