Starting with 4D 21, your HTTPS requests can now use a certificate stored in the Windows Certificate Store instead of one saved on disk. This is particularly useful when the client-side of HTTPS requests needs to use local certificates.
Using certificates from the Windows Certificate Store in HTTPS requests has been a popular feature request from 4D Developers on the 4D Forum. Once again, we’ve listened, and 4D 21 delivers.
Setting the Certificate
In HTTP requests, defining which certificate to use from the Windows Certificate Store is straightforward. Just set its name in the new storeCertificateName attribute of the options object passed to the new() function. Here’s a code example:
var $options:={storeCertificateName: "myCertificateName"}
var $request:=4D.HTTPRequest.new($url; $options)
Of course, you can also set the certificate name for an HTTP agent, as shown in the following example:
var $options:={storeCertificateName: "myCertificateName"}
var $agent:=4D.HTTPAgent.new($options)
var $request:=4D.HTTPRequest.new($url; {agent: $agent})
Installing a Certificate in Windows
Registering a certificate in the Windows Certificate Store is quite simple. The easiest way is to use a PKCS#12 certificate, which contains both a private key and an identity certificate. Many tools can generate these certificates.
In Windows Explorer, just double-click the PKCS#12 certificate file and follow the wizard steps, as shown in the video below.
⚠️ One step is particularly important: in the third step of the wizard, make sure to check the “Mark this key as exportable” checkbox. If you skip this, 4D won’t be able to use the certificate.
That’s it! The certificate is safely stored and ready to be used in 4D!
This new feature is currently only available on Windows. We’re currently evaluating support for macOS Keychain.
We hope this new feature meets your expectations. As always, feel free to share your feedback on the 4D Forum.
Happy coding!
