DataFlex
DataFlex
Use a PEM TLS Client Certificate
See more SMTP Examples
Demonstrates the Chilkat MailMan.SetSslClientCertPem method, which sets the client-side certificate for SSL/TLS connections, loading it from PEM data or from a PEM file. The first argument may contain the PEM text itself or a path to a PEM file; the second is the PEM password. This example loads the client certificate from a PEM file.
Background: PEM is the familiar Base64 text format bracketed by
-----BEGIN CERTIFICATE----- lines, and a single PEM can hold both a certificate and its (optionally encrypted) private key. It is the common format in Unix/OpenSSL environments, whereas PFX is more typical on Windows. Because this method accepts either the PEM text or a filename, you can supply credentials straight from a config value or secret store without writing them to disk.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMailman
String sTemp1
Move False To iSuccess
// Demonstrates the MailMan.SetSslClientCertPem method, which sets the client-side
// certificate for SSL/TLS connections, loading it from PEM data or from a PEM file. The
// 1st argument may contain PEM text or a PEM file path; the 2nd is the PEM password.
Get Create (RefClass(cComChilkatMailMan)) To hoMailman
If (Not(IsComObjectCreated(hoMailman))) Begin
Send CreateComObject of hoMailman
End
// Configure the SMTP server connection.
Set ComSmtpHost Of hoMailman To "smtp.example.com"
Set ComSmtpPort Of hoMailman To 465
Set ComSmtpSsl Of hoMailman To True
Set ComSmtpUsername Of hoMailman To "user@example.com"
Set ComSmtpPassword Of hoMailman To "myPassword"
// Load the client certificate from a PEM file.
Get ComSetSslClientCertPem Of hoMailman "qa_data/certs/client.pem" "pem_password" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComVerifySmtpLogin Of hoMailman To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Connected using a PEM TLS client certificate."
// Note: The path "qa_data/certs/client.pem" is a relative local filesystem path,
// relative to the current working directory of the running application.
End_Procedure