当前位置: 首页>>代码示例>>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;未经允许,请勿转载。