SSL Client Workspace
 
"Make sure that vast_client.pem, vast_client_key.pem and vast_ca.pem
are in a directory of your choice and referenced in <dir>. The
following example uses Unix style path separators. This client code
performs a verification of the server certificate."
 
| config rv anSciSocketAddress secureSocket buffer msg |
 
[config := SciSslSocketConfiguration new
certificateFilename: '<dir>/vast_client.pem';
privateKeyFilename: '<dir>/vast_client_key.pem';
caFile: '<dir>/vast_ca.pem';
minProtocol: SciSslConstants::TLS1_3_VERSION;
verify: SciSslConstants::SSL_VERIFY_PEER
| SciSslConstants::SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
verifyDepth: 1;
yourself.
anSciSocketAddress :=
(SciSocketAddress fromString: '127.0.0.1' )
family: SciSocketConstants::AFINET;
port: 4466.
secureSocket := SciSslSocket newStreamSocket.
(rv := secureSocket connect: anSciSocketAddress) isSciError
ifTrue: [ secureSocket close. self halt ].
(rv := secureSocket sslInitialize: config) isSslError
ifTrue: [ secureSocket close. self halt ].
(rv := secureSocket sslConnect) isSslError
ifTrue: [ secureSocket close. self halt ].
 
rv := secureSocket
send: ('Hello ', (Character value: 0) asString, 'World!') asPSZ
length: 12
startingAt: 1
flags: 0.
rv isSslError ifTrue: [ 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: 'SslClient Got -> ', msg asString, ' <- '.
secureSocket close. ] fork.
Last modified date: 12/06/2023