Tech Tip: How to issue a Certificate Signing Request for TLS protocol (HTTPS)
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: January 31, 2022
When setting up TLS for web server, an encryption key pair and Certificate Signing Request (CSR) must be generated first. Below is an example of how to create a new key pair and issue a CSR.
var $privateKey; $publicKey; $CSR : Blob // Generate new key pair GENERATE ENCRYPTION KEYPAIR($privateKey; $publicKey; 2048) // Set up Certificate Signing Request info ARRAY LONGINT($TLScode; 6) ARRAY TEXT($TLSinfo; 6) // Common Name $TLScode{1}:=13 $TLSinfo{1}:="www.mydomain.com" // Country Name (2 Letters) $TLScode{2}:=14 $TLSinfo{2}:="US" // Locality Name $TLScode{3}:=15 $TLSinfo{3}:="My City" // State or Province Name $TLScode{4}:=16 $TLSinfo{4}:="My State" // Organization Name $TLScode{5}:=17 $TLSinfo{5}:="My Company" // Organization Unit $TLScode{6}:=18 $TLSinfo{6}:="My Department" // Generate CSR GENERATE CERTIFICATE REQUEST($privateKey; $CSR; $TLScode; $TLSinfo) // Save CSR to file BLOB TO DOCUMENT("csr.txt"; $CSR) // Save private key to file BLOB TO DOCUMENT("key.pem"; $privateKey) |
The resulting csr.txt and key.pem files will be created next to the project folder. Send the CSR to a certification authority to have it verified.