Xbasic

a5http_AddCertFileToCARoots Function

Syntax

dim result as CallResult = a5http_AddCertFileToCARoots(certFile as c [, certName as c])

Arguments

certFileCharacter

The location of the certificate file to add.

certNameCharacter

Default = "". The certificate name.

Returns

resultCallResult

Returns a CallResult object. The object's error property will be .f. if the call succeeded. If .t., the text property will contain an error message.

Description

Adds the specified certificate file to the CARoots file (trusted root certificates) used by http_* client functions and curl operations.

Discussion

The example below demonstrates adding a certificate to the CA Root:

Example

'a request to localhost fails because it uses a self-signed (untrusted) certificate
?http_get("https://localhost").error_text
= "Could not connect to server: Secure Sockets Layer was not able to verify certificate."

'add the certificate that the server is configured to use into the CARoots file
?a5http_AddCertFileToCARoots(httpd_settings_get().SSL_CertificateFile)
= Canceled = .F.
Code = 0
Error = .F.
NativeCode = 0
NativeText = ""
ReturnDataValue = <No data returned>
RowsAffected = 0
StackTrace = ""
Success = .T.
Text = "Success"
TextAndStackTrace = ""

'make another request to localhost and see that here is no longer an error verifying the certificate
?http_get("https://localhost").error_text
= ""