SSL Server Workspace
"Make sure that vast_server.pem and vast_server_key.pem are in a directory of your choice and referenced in <dir>.
The following example uses Unix style path separators."
| config anSciSocketAddress listenSocket secureSocket rv buffer msg |
 
[config := SciSslSocketConfiguration new
certificateFilename: '<dir>/vast_server.pem';
privateKeyFilename: '<dir>/vast_server_key.pem';
minProtocol: SciSslConstants::TLS1_3_VERSION;
yourself.
anSciSocketAddress := (SciSocketAddress new)
address: SciSocketConstants::INADDRANY;
port: 4466.
listenSocket := SciSslSocket newStreamSocket.
(rv := listenSocket bind: anSciSocketAddress) isSciError
ifTrue: [ self halt ].
(rv := listenSocket listen: 5) isSciError ifTrue: [ self halt ].
(secureSocket := listenSocket accept) isSciError ifTrue: [ self halt ].
listenSocket close.
(rv := secureSocket sslInitialize: config) isSslError
ifTrue: [ secureSocket close. self halt ].
(rv := secureSocket sslAccept) isSslError
ifTrue: [ secureSocket close. self halt ].
buffer := ByteArray new: 4096.
(rv := secureSocket recv: buffer length: 4096 startingAt: 1 flags: 0)
isSslError ifTrue: [ self halt ].
msg := buffer copyFrom: 1 to: rv.
Transcript cr; nextPutAll: 'SslServer Got: ', msg asString.
rv := secureSocket
send: 'I hear you.' abrAsPSZ
length: 11
startingAt: 1
flags: 0.
rv isSslError ifTrue: [ self halt ].
secureSocket close. ] fork
Last modified date: 12/06/2023