小编Adr*_*sot的帖子

使用.NET SslStream进行SSL安全重新协商

我正在尝试与.NET SslStream进行安全的重新协商,但我不确定如何实现它,或者它是否可能.我的目标是使用服务器的相同证书更新共享密钥.

我使用OpenSSL设置了一个服务器:

s_server -accept 443 -key privkey.pem
Run Code Online (Sandbox Code Playgroud)

这是我的客户端代码:

public static void RunClient()
{
    TcpClient client = new TcpClient("localhost", 443);
    Console.WriteLine("Client connected.");
    SslStream sslStream = new SslStream(innerStream: client.GetStream(), leaveInnerStreamOpen: true, userCertificateValidationCallback: (a,b,c,d) => true, userCertificateSelectionCallback: null);
    sslStream.AuthenticateAsClient("localhost");
    byte[] message = Encoding.UTF8.GetBytes("Hello from the client.");
    sslStream.Write(message);
    sslStream.Dispose();
    // if code below is commented, there's no error.
    sslStream = new SslStream(innerStream: client.GetStream(), leaveInnerStreamOpen: true, userCertificateValidationCallback: (a, b, c, d) => true, userCertificateSelectionCallback: null);
    message = Encoding.UTF8.GetBytes("Hello from the client again, renegotiated.");
    sslStream.AuthenticateAsClient("localhost"); …
Run Code Online (Sandbox Code Playgroud)

.net c# windows ssl

9
推荐指数
0
解决办法
472
查看次数

标签 统计

.net ×1

c# ×1

ssl ×1

windows ×1