Visual FoxPro
Visual FoxPro
Get the Configured Server-Side TLS Certificate
See more Socket/SSL/TLS Examples
Demonstrates Socket.GetMyServerCert, which copies the TLS server certificate configured by InitSslServer into a Cert object.
The file path is relative to the application's current working directory. An absolute path may also be used. Supply the path appropriate to your own environment.
Background. This is intended for a socket acting as a TLS server and returns false when no server certificate has been configured.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loSocket
LOCAL lcPfxPassword
LOCAL loCert
LOCAL loMyCert
lnSuccess = 0
loSocket = CreateObject('Chilkat.Socket')
* The file path is relative to the application's current working directory. An absolute path
* may also be used. Supply the path appropriate to your own environment.
* The PFX password should come from a secure source rather than being hard-coded.
lcPfxPassword = "myPfxPassword"
loCert = CreateObject('Chilkat.Cert')
lnSuccess = loCert.LoadPfxFile("qa_data/server.pfx",lcPfxPassword)
IF (lnSuccess = 0) THEN
? loCert.LastErrorText
RELEASE loSocket
RELEASE loCert
CANCEL
ENDIF
lnSuccess = loSocket.InitSslServer(loCert)
IF (lnSuccess = 0) THEN
? loSocket.LastErrorText
RELEASE loSocket
RELEASE loCert
CANCEL
ENDIF
* Copy the TLS server certificate configured by InitSslServer, then inspect it.
loMyCert = CreateObject('Chilkat.Cert')
lnSuccess = loSocket.GetMyServerCert(loMyCert)
IF (lnSuccess = 0) THEN
? loSocket.LastErrorText
RELEASE loSocket
RELEASE loCert
RELEASE loMyCert
CANCEL
ENDIF
? "Server certificate subject: " + loMyCert.SubjectCN
RELEASE loSocket
RELEASE loCert
RELEASE loMyCert