當前位置: 首頁>>代碼示例>>C#>>正文


C# SafeHandles.SafeSslHandle類代碼示例

本文整理匯總了C#中Microsoft.Win32.SafeHandles.SafeSslHandle的典型用法代碼示例。如果您正苦於以下問題:C# SafeSslHandle類的具體用法?C# SafeSslHandle怎麽用?C# SafeSslHandle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SafeSslHandle類屬於Microsoft.Win32.SafeHandles命名空間,在下文中一共展示了SafeSslHandle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SslConnectionInfo

        public SslConnectionInfo(SafeSslHandle sslContext)
        {
            string protocolVersion = Interop.Ssl.GetProtocolVersion(sslContext);
            Protocol = (int)MapProtocolVersion(protocolVersion);

            int dataCipherAlg;
            int keyExchangeAlg;
            int dataHashAlg;
            int dataKeySize;
            int dataHashKeySize;

            if (!Interop.Ssl.GetSslConnectionInfo(
                sslContext,
                out dataCipherAlg,
                out keyExchangeAlg,
                out dataHashAlg,
                out dataKeySize,
                out dataHashKeySize))
            {
                throw Interop.OpenSsl.CreateSslException(SR.net_ssl_get_connection_info_failed);
            }

            DataCipherAlg = dataCipherAlg;
            KeyExchangeAlg = keyExchangeAlg;
            DataHashAlg = dataHashAlg;
            DataKeySize = dataKeySize;
            DataHashKeySize = dataHashKeySize;

            //Openssl does not provide a way to return a exchange key size.
            //It internally does calculate the key size before generating key to exchange
            //It is not a constant (Algorthim specific) either that we can hardcode and return. 
            KeyExchKeySize = 0;
        }
開發者ID:dotnet,項目名稱:corefx,代碼行數:33,代碼來源:SslConnectionInfo.Unix.cs

示例2: GetSslConnectionInfo

 internal static extern bool GetSslConnectionInfo(
     SafeSslHandle ssl,
     out int dataCipherAlg,
     out int keyExchangeAlg,
     out int dataHashAlg,
     out int dataKeySize,
     out int hashKeySize);
開發者ID:AndreGleichner,項目名稱:corefx,代碼行數:7,代碼來源:Interop.Ssl.cs

示例3: SSL_get_client_CA_list

        internal static SafeSharedX509NameStackHandle SSL_get_client_CA_list(SafeSslHandle ssl)
        {
            Interop.Crypto.CheckValidOpenSslHandle(ssl);

            SafeSharedX509NameStackHandle handle = SSL_get_client_CA_list_private(ssl);

            if (!handle.IsInvalid)
            {
                handle.SetParent(ssl);
            }

            return handle;
        }
開發者ID:bbologna,項目名稱:corefx,代碼行數:13,代碼來源:Interop.libssl.cs

示例4: SslConnectionInfo

        internal SslConnectionInfo(SafeSslHandle sslContext)
        {
            string protocolVersion = Interop.Ssl.GetProtocolVersion(sslContext);
            Protocol = (int)MapProtocolVersion(protocolVersion);

            if (!Interop.Ssl.GetSslConnectionInfo(
                sslContext,
                out DataCipherAlg,
                out KeyExchangeAlg,
                out DataHashAlg,
                out DataKeySize))
            {
                throw Interop.OpenSsl.CreateSslException(SR.net_ssl_get_connection_info_failed);
            }
            // TODO (Issue #3362) map key sizes
        }
開發者ID:jussimar,項目名稱:corefx,代碼行數:16,代碼來源:SslConnectionInfo.cs

示例5: DoSslHandshake

        internal static bool DoSslHandshake(SafeSslHandle context, byte[] recvBuf, int recvOffset, int recvCount, out byte[] sendBuf, out int sendCount)
        {
            sendBuf = null;
            sendCount = 0;
            if ((recvBuf != null) && (recvCount > 0))
            {
                BioWrite(context.InputBio, recvBuf, recvOffset, recvCount);
            }

            libssl.SslErrorCode error;
            int retVal = libssl.SSL_do_handshake(context);

            if (retVal != 1)
            {
                error = GetSslError(context, retVal);

                if ((retVal != -1) || (error != libssl.SslErrorCode.SSL_ERROR_WANT_READ))
                {
                    throw CreateSslException(context, SR.net_ssl_handshake_failed_error, retVal);
                }
            }

            sendCount = libssl.BIO_ctrl_pending(context.OutputBio);

            if (sendCount > 0)
            {
                sendBuf = new byte[sendCount];

                try
                {
                    sendCount = BioRead(context.OutputBio, sendBuf, sendCount);
                }
                finally
                {
                    if (sendCount <= 0)
                    {
                        sendBuf = null;
                        sendCount = 0;
                    }
                }
            }

            return ((libssl.SSL_state(context) == (int)libssl.SslState.SSL_ST_OK));

        }
開發者ID:jango2015,項目名稱:corefx,代碼行數:45,代碼來源:Interop.OpenSsl.cs

示例6: QueryChannelBinding

        internal static SafeChannelBindingHandle QueryChannelBinding(SafeSslHandle context, ChannelBindingKind bindingType)
        {
            SafeChannelBindingHandle bindingHandle;
            switch (bindingType)
            {
                case ChannelBindingKind.Endpoint:
                    bindingHandle = new SafeChannelBindingHandle(bindingType);
                    QueryEndPointChannelBinding(context, bindingHandle);
                    break;

                case ChannelBindingKind.Unique:
                    bindingHandle = new SafeChannelBindingHandle(bindingType);
                    QueryUniqueChannelBinding(context, bindingHandle);
                    break;

                default:
                    // Keeping parity with windows, we should return null in this case.
                    bindingHandle = null;
                    break;
            }

            return bindingHandle;
        }
開發者ID:kkurni,項目名稱:corefx,代碼行數:23,代碼來源:Interop.OpenSsl.cs

示例7: DoSslHandshake

        internal static bool DoSslHandshake(SafeSslHandle context, byte[] recvBuf, int recvOffset, int recvCount, out byte[] sendBuf, out int sendCount)
        {
            sendBuf = null;
            sendCount = 0;
            if ((recvBuf != null) && (recvCount > 0))
            {
                BioWrite(context.InputBio, recvBuf, recvOffset, recvCount);
            }

            int retVal = Ssl.SslDoHandshake(context);

            if (retVal != 1)
            {
                Exception innerError;
                Ssl.SslErrorCode error = GetSslError(context, retVal, out innerError);

                if ((retVal != -1) || (error != Ssl.SslErrorCode.SSL_ERROR_WANT_READ))
                {
                    throw new SslException(SR.Format(SR.net_ssl_handshake_failed_error, error), innerError);
                }
            }

            sendCount = Crypto.BioCtrlPending(context.OutputBio);

            if (sendCount > 0)
            {
                sendBuf = new byte[sendCount];

                try
                {
                    sendCount = BioRead(context.OutputBio, sendBuf, sendCount);
                }
                finally
                {
                    if (sendCount <= 0)
                    {
                        sendBuf = null;
                        sendCount = 0;
                    }
                }
            }

            bool stateOk = Ssl.IsSslStateOK(context);
            if (stateOk)
            {
                context.MarkHandshakeCompleted();
            }
            return stateOk;
        }
開發者ID:kkurni,項目名稱:corefx,代碼行數:49,代碼來源:Interop.OpenSsl.cs

示例8: IsSslStateOK

 internal static extern bool IsSslStateOK(SafeSslHandle ssl);
開發者ID:AndreGleichner,項目名稱:corefx,代碼行數:1,代碼來源:Interop.Ssl.cs

示例9: SslDoHandshake

 internal static extern int SslDoHandshake(SafeSslHandle ssl);
開發者ID:AndreGleichner,項目名稱:corefx,代碼行數:1,代碼來源:Interop.Ssl.cs

示例10: SslSetBio

 internal static extern void SslSetBio(SafeSslHandle ssl, SafeBioHandle rbio, SafeBioHandle wbio);
開發者ID:AndreGleichner,項目名稱:corefx,代碼行數:1,代碼來源:Interop.Ssl.cs

示例11: SslGetClientCAList_private

 private static extern SafeSharedX509NameStackHandle SslGetClientCAList_private(SafeSslHandle ssl);
開發者ID:AndreGleichner,項目名稱:corefx,代碼行數:1,代碼來源:Interop.Ssl.cs

示例12: GetPeerCertificateChain

 internal static SafeSharedX509StackHandle GetPeerCertificateChain(SafeSslHandle context)
 {
     return Ssl.SslGetPeerCertChain(context);
 }
開發者ID:kkurni,項目名稱:corefx,代碼行數:4,代碼來源:Interop.OpenSsl.cs

示例13: QueryUniqueChannelBinding

        private static void QueryUniqueChannelBinding(SafeSslHandle context, SafeChannelBindingHandle bindingHandle)
        {
            bool sessionReused = Ssl.SslSessionReused(context);
            int certHashLength = context.IsServer ^ sessionReused ?
                                 Ssl.SslGetPeerFinished(context, bindingHandle.CertHashPtr, bindingHandle.Length) :
                                 Ssl.SslGetFinished(context, bindingHandle.CertHashPtr, bindingHandle.Length);

            if (0 == certHashLength)
            {
                throw CreateSslException(SR.net_ssl_get_channel_binding_token_failed);
            }

            bindingHandle.SetCertHashLength(certHashLength);
        }
開發者ID:kkurni,項目名稱:corefx,代碼行數:14,代碼來源:Interop.OpenSsl.cs

示例14: GetProtocolVersion

 internal static string GetProtocolVersion(SafeSslHandle ssl)
 {
     return Marshal.PtrToStringAnsi(SslGetVersion(ssl));
 }
開發者ID:AndreGleichner,項目名稱:corefx,代碼行數:4,代碼來源:Interop.Ssl.cs

示例15: SslGetVersion

 private static extern IntPtr SslGetVersion(SafeSslHandle ssl);
開發者ID:AndreGleichner,項目名稱:corefx,代碼行數:1,代碼來源:Interop.Ssl.cs


注:本文中的Microsoft.Win32.SafeHandles.SafeSslHandle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。