次のコードを使用して、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はAssyncCallsを解決できますか;-)多分私はこれのためにいくつかの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)
私が最終的に達成したいのは、クライアントが接続されている暗号スイートをリストし、後で指定することです。(私が知っているWiresharkを使用できます;-))