Tech Tip: Securing 4D Client-Server Communications with TLS Certificates
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: May 29, 2025
When deploying a 4D application, ensuring secure client-server communications is critical, especially when sensitive data is exchanged. Without proper TLS encryption, communications are vulnerable to interception. You may need to set up certificates for local testing, deploy trusted certificates for production, or leverage 4D’s built-in features for simplified security.
For development or testing, use OpenSSL to create a self-signed certificate to encrypt 4D client-server communications.Generate a private key and CA certificate:
- openssl genrsa -out ca.key 2048
- openssl req -x509 -new -nodes -key ca.key -sha256 -days 365 -out ca.pem
- openssl req -new -key server.key -out server.csr -config san.cnf
[req]
default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn
[dn]
CN = localhost
[req_ext]
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
IP.1 = 127.0.0.1
Sign the CSR to produce a server certificate:
openssl x509 -req -in server.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out cert.pem -days 365 -sha256 -extfile san.cnf -extensions req_ext
- Deploy cert.pem and key.pem to the Resources folder of the 4D server and each client.
- Ensure CN and SAN match your server’s hostname or IP to avoid connection issues.
Obtain a certificate using certbot: certbot certonly --standalone -d yourdomain.com
Find cert.pem and key.pem in /etc/letsencrypt/live/yourdomain.com/, then copy them to the Resources folder of the 4D server and clients.
Verify the certificate:
- openssl x509 -in cert.pem -text -noout