System.Net.Security.SslStream derives from System.Net.Security.AuthenticatedStream and provides a Stream for SSL/TLS communication. System.Net.Security.SslStream can be combined with System.Net.Sockets.TcpClient to establish establish HTTPS connection: $domain = 'renenyffenegger.ch' $conn = new-object System.Net.Sockets.TcpClient($domain, 443) [System.Net.Sockets.NetworkStream] $connStream = $conn.GetStream() $sslStream = New-Object System.Net.Security.SslStream($connStream,$false) $sslStream.AuthenticateAsClient($domain) $reader = new-object System.IO.StreamReader($sslStream) $writer = new-object System.IO.StreamWriter($sslStream) $writer.AutoFlush = $true # # Send request header, terminated # by an empty line # $writer.WriteLine('GET / HTTP/1.1') $writer.WriteLine("Host: $domain") $writer.WriteLine('') # # Read response from server. # while ($reader.Peek() -ne -1) { write-host ($reader.ReadLine()) }
AuthenticateAsClient() | |
AuthenticateAsClientAsync() | |
AuthenticateAsServer() | |
AuthenticateAsServerAsync() | |
BeginAuthenticateAsClient() | |
BeginAuthenticateAsServer() | |
BeginRead() | |
BeginWrite() | |
CanRead | |
CanSeek | |
CanTimeout | |
CanWrite | |
CheckCertRevocationStatus | |
CipherAlgorithm | |
CipherStrength | |
Dispose() | |
DisposeAsync() | |
EndAuthenticateAsClient() | |
EndAuthenticateAsServer() | |
EndRead() | |
EndWrite() | |
Finalize() | |
Flush() | |
FlushAsync() | |
HashAlgorithm | |
HashStrength | |
IsAuthenticated | |
IsEncrypted | |
IsMutuallyAuthenticated | |
IsServer | |
IsSigned | |
KeyExchangeAlgorithm | |
KeyExchangeStrength | |
Length | |
LocalCertificate | |
NegotiateClientCertificateAsync() | |
NegotiatedApplicationProtocol | |
NegotiatedCipherSuite | |
Position | |
Read() | |
ReadAsync() | |
ReadByte() | |
ReadTimeout | |
RemoteCertificate | |
Seek() | |
SetLength() | |
ShutdownAsync() | |
SslProtocol | |
TargetHostName | |
TransportContext | |
Write() | |
WriteAsync() | |
WriteTimeout |