DataFlex
DataFlex
Use a PFX TLS Client Certificate
See more SMTP Examples
Demonstrates the Chilkat MailMan.SetSslClientCertPfx method, which sets the client-side certificate for SSL/TLS connections, loading it from a PFX/PKCS#12 file. The first argument is the path to the PFX file and the second is its password. This example loads a client certificate directly from a PFX.
Background: This is the convenience form of
SetSslClientCert: rather than loading a Cert object first, you point straight at the PFX file and password. A PFX (PKCS#12) bundles the certificate with its private key — exactly what mutual TLS requires, since the client must prove possession of the key during the handshake. It is the usual client-credential format on Windows.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMailman
String sTemp1
Move False To iSuccess
// Demonstrates the MailMan.SetSslClientCertPfx method, which sets the client-side
// certificate for SSL/TLS connections, loading it from a PFX/PKCS#12 file. The 1st argument
// is the PFX path and the 2nd is the PFX 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 directly from a PFX file.
Get ComSetSslClientCertPfx Of hoMailman "qa_data/certs/client.pfx" "pfx_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 PFX TLS client certificate."
// Note: The path "qa_data/certs/client.pfx" is a relative local filesystem path,
// relative to the current working directory of the running application.
End_Procedure