本文整理汇总了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;
}
示例2: GetSslConnectionInfo
internal static extern bool GetSslConnectionInfo(
SafeSslHandle ssl,
out int dataCipherAlg,
out int keyExchangeAlg,
out int dataHashAlg,
out int dataKeySize,
out int hashKeySize);
示例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;
}
示例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
}
示例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));
}
示例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;
}
示例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;
}
示例8: IsSslStateOK
internal static extern bool IsSslStateOK(SafeSslHandle ssl);
示例9: SslDoHandshake
internal static extern int SslDoHandshake(SafeSslHandle ssl);
示例10: SslSetBio
internal static extern void SslSetBio(SafeSslHandle ssl, SafeBioHandle rbio, SafeBioHandle wbio);
示例11: SslGetClientCAList_private
private static extern SafeSharedX509NameStackHandle SslGetClientCAList_private(SafeSslHandle ssl);
示例12: GetPeerCertificateChain
internal static SafeSharedX509StackHandle GetPeerCertificateChain(SafeSslHandle context)
{
return Ssl.SslGetPeerCertChain(context);
}
示例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);
}
示例14: GetProtocolVersion
internal static string GetProtocolVersion(SafeSslHandle ssl)
{
return Marshal.PtrToStringAnsi(SslGetVersion(ssl));
}
示例15: SslGetVersion
private static extern IntPtr SslGetVersion(SafeSslHandle ssl);