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 msg |
 
[config := SciSslSocketConfiguration new
  certificateFilename: '<dir>/vast_client.pem';   
  privateKeyFilename: '<dir>/vast_client_key.pem';
  caFile: '<dir>/vast_ca.pem';
  sslVersion: 'TLS';
  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: 4433.
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 World!' asPSZ 
    length: 12 
    startingAt: 1 
    flags: 0.
rv isSslError ifTrue: [ self halt ].
 
msg := ByteArray new: 4096.
(rv := secureSocket recv: msg length: 4096 startingAt: 1 flags: 0) 
    isSslError ifTrue: [ self halt ].
Transcript cr; nextPutAll: 'SslClient Got -> ', msg asString trimNull, 
' <-  '.
secureSocket close. ] fork.
Last modified date: 11/06/2015