使用以下代码,我可以建立 SSL 连接:
$cert = dir cert:\CurrentUser\My | where {$_.Subject -like "*Alice*"}
$computerName = "google.com"
$port = "443"
$socket = New-Object Net.Sockets.TcpClient($computerName, $port)
$stream = $socket.GetStream()
$sslStream = New-Object System.Net.Security.SslStream $stream,$false
$sslStream.AuthenticateAsClient($computerName)
$sslStream
这工作正常。但现在我不想为身份验证添加客户端证书。认为我只需要替换
$sslStream.AuthenticateAsClient($computerName)
和
$sslStream.BeginAuthenticateAsClient($computerName,$cert,"SslProtocols",$false,"Foo" ,"Bar")
但我并不幸运地得到了正确的论点。Sombody 可以解决 Assync 调用吗 ;-) 也许我需要一些 C# 代码?!?
论据是:
System.IAsyncResult BeginAuthenticateAsClient(
string targetHost,
System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates,
System.Security.Authentication.SslProtocols enabledSslProtocols,
bool checkCertificateRevocation,
System.AsyncCallback asyncCallback,
System.Object asyncState)
我最终想要实现的是列出并稍后指定客户端连接到的 CipherSuites。(我可以使用我知道的 Wireshark ;-))