我尝试与.NET SslStream进行安全的重新协商,但我不确定如何实现它,或者甚至是否可能。我的目标是使用服务器的相同证书续订共享密钥。
我使用OpenSSL设置服务器:
submit(){
this.dataService.getData().then(() => {
console.log('after executing service');
this.router.navigate(['/view']);
};
};
这是我的客户代码:
s_server -accept 443 -key privkey.pem
第二次调用AuthenticateAsClient,在新的SslStream上失败,"对SSPI的调用失败,请参阅内部异常。"。内部异常是" Win32Exception:收到的消息是意外的或格式错误"。
在服务器端,我也收到错误:
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");
sslStream.Write(message);
//
client.Close();
Console.WriteLine("Client closed.");
}
public static int Main(string[] args)
{
RunClient();
return 0;
}
你知道这里有什么问题,或者我的用例是否支持SslStream?