Blog | G5 Cyber Security

Form Encryption Over HTTP

TL;DR

No, you can’t reliably encrypt a form submission if the address bar shows ‘HTTP’. The data is still sent in plain text before encryption can begin. You must use HTTPS to secure the entire connection.

Why HTTP Doesn’t Work for Encryption

When your browser connects to a website using HTTP, all the information exchanged (including form data) travels as plain text. Even if you try to encrypt it on the client-side after the page loads, it’s still vulnerable because:

How to Secure Form Submissions

The correct solution is to use HTTPS (Hypertext Transfer Protocol Secure). Here’s how:

1. Get an SSL/TLS Certificate

  1. Choose a Certificate Authority (CA): Companies like Let’s Encrypt, DigiCert, Sectigo, and GlobalSign provide SSL/TLS certificates. Let’s Encrypt offers free certificates.
  2. Generate a Certificate Signing Request (CSR): This is done on your web server. The process varies depending on your server software (Apache, Nginx, IIS). For example, using OpenSSL:
    openssl req -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
  3. Submit the CSR to the CA: Follow the CA’s instructions for verification (usually involving email or DNS records).
  4. Install the Certificate: Once verified, download and install the certificate on your web server. This also usually involves configuring your server software.

2. Configure Your Web Server to Use HTTPS

This step depends heavily on your web server.

Example Nginx configuration snippet:

server {
    listen 443 ssl;
    server_name yourdomain.com;

    ssl_certificate /path/to/your_certificate.pem;
    ssl_certificate_key /path/to/your_private_key.pem;

    # Other server configuration options...
}

3. Redirect HTTP to HTTPS

Force all traffic to use the secure HTTPS version of your website.

4. Update Form Action Attributes

Change the `action` attribute of your forms to use HTTPS URLs:

<form action="https://yourdomain.com/submit-form" method="post">

Client-Side Encryption (Not a Replacement for HTTPS)

While client-side encryption can add an extra layer of security, it does not solve the problem of sending data over HTTP. It only protects the data *after* it’s been intercepted. Consider using JavaScript libraries to encrypt form fields before submission, but always in conjunction with HTTPS.

Testing Your Setup

Exit mobile version