Search notes:

System.Net.Security.SslStream (class)

System.Net.Security.SslStream derives from System.Net.Security.AuthenticatedStream and provides a Stream for SSL/TLS communication.

Simple HTTPS Client

The following simple example demonstrate how 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())
}

Methods and properties

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

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1788457429, '216.73.217.21', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/dot-net/namespaces-classes/System/Net/Security/SslStream(123): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78