Example: web_set_certificate_ex
In the following example, the web_set_certificate_ex function provides information about the certificate's location, type, and password.
web_set_certificate_ex(
"CertFilePath=cert1.pem",
"CertFormat=PEM",
"KeyFilePath=key1.pem",
"KeyFormat=PEM",
"Password=donkey",
LAST );
An example using CertThumbprint:
web_set_certificate_ex(
"CertThumbprint=cd610c0b387c6eb670e2c564abb44ead2a3186d9",
"CertFormat=PEM",
"KeyFilePath=key1.pem",
"KeyFormat=PEM",
"Password=donkey",
LAST );
Note: You can use any of CertFilePath, CertIndex and CertThumbprint to locate a certificate. The API will only process one of them, in the following order of precedence: CertFilePath, CertThumbprint, CertIndex. For example, in the following case, CertIndex will be ignored.
web_set_certificate_ex("CertIndex=8", "CertThumbprint=cd610c0b387c6eb670e2c564abb44ead2a3186d9", LAST);
In the following example, the web_set_certificate_ex function clears a previously set certificate. Because the certificate cannot be cleared for a working TLS session, the web_set_sockets_option function is called first in order to stop and reset the working TLS session:
web_set_sockets_option("CLOSE_KEEPALIVE_CONNECTIONS", "1");
web_set_sockets_option("SSL_VERSION", "AUTO");
web_set_certificate_ex("CertFilePath=NULL",LAST);