Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save romanvanderkrogt/1df30bc1857943d4aef6c9beeadd1244 to your computer and use it in GitHub Desktop.

Select an option

Save romanvanderkrogt/1df30bc1857943d4aef6c9beeadd1244 to your computer and use it in GitHub Desktop.
Generate self-signed certificate for HAProxy
# Generate a unique private key (KEY)
sudo openssl genrsa -out mydomain.key 2048
# Generating a Certificate Signing Request (CSR). Note "Common Name" should be server DNS
sudo openssl req -new -key mydomain.key -out mydomain.csr
# Creating a Self-Signed Certificate (CRT), see below for the contents of ssl.conf
sudo openssl x509 -req -days 365 -in mydomain.csr -signkey mydomain.key -out mydomain.crt -extensions req_ext -extfile ssl.conf
# Append KEY and CRT to mydomain.pem
sudo bash -c 'cat mydomain.key mydomain.crt > /opt/textiq/config/haproxy/cert.pem'
------ ssl.conf template for use in step (3) ----
[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
req_extensions = req_ext
prompt = no
[ req_distinguished_name ]
commonName = <ip>
[ req_ext ]
subjectAltName = IP:<ip>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment