Xbasic

INET::SSLContext Class

Description

Methods for working with SSL certificates and encrypted data.

Discussion

When using SSL, you need to provide a server side certificate, a private key, and often a password as part of the context. The INET::SSLSocket method automatically creates the context object, which can be accessed by referencing the Context property. Alternatively, you can create a context object and assign it to each new INET::SSLSocket. Since initializing the context is fairly expensive to establish, you can get better performance by sharing the context among sockets.

 Example

This example does not use the INET::SSLContext object.

dim Socket as INET::SSLSocket
Socket.Context.CertificateFile = CertificatePath + "secure.alphafiveonline.com.crt"
Socket.Context.PrivateKeyFile = CertificatePath + "secure.alphafiveonline.com.key"
Socket.Context.password = ""

This example uses the INET::SSLContext object.

dim Context as SQLContext
dim Socket as INET::SSLSocket
Context.CertificateFile = CertificatePath + "secure.alphafiveonline.com.crt"
Context.PrivateKeyFile = CertificatePath + "secure.alphafiveonline.com.key"
Context.password = ""
if .not. Context.EstablishContext()
' Check Context.callresult and write code to handle error
end if
Socket.Context = Context

Properties

PrivateKeyFileCharacter

Type "C". String PrivateKeyFile property. The path and name of the private key file.

CertificateFileCharacter

Type "C". The path and name of the SSL Server Certificate file.

CertificateAuthorityFileCharacter

Type "C". The path and name of the SSL Certificate Authority file.

CertificateChainFileCharacter

Type "C". The path and name of the SSL Certificate Chain file.

PasswordCharacter

Type "C". String Password property

CallResult

Information about success or failure.

CipherListCharacter

Type "C". String CipherList property

RequireValidCertificateLogical

Type "L". Logical RequireValidCertificate property

Methods

CreateCertificateRequest Method

Create a reqest for a certificate.

CreatePrivateKey Method

Create a private key with an optional password and write to KeyFileName Note: Bits must be one of 512, 1024 or 2048

CreateTestCertificate Method

Create a server test certificate using an existing private key.

DecryptString Method

Decrypts a string which has been encrypted and converted to base64 encoding.

EncryptString Method

Encrypts the string provided and encodes the encryption result using base64 encoding. Note: This function is optional. Use it if you want to verify a context.

EstablishContext Method

Create and verify SSL parameters and settings. Note: This function is optional. Use it if you want to verify a context.

Limitations

Desktop applications only.

See Also