-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support setting openssl certs for openldap
- Loading branch information
Showing
3 changed files
with
195 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# Set variables | ||
ROOT_SUBJECT="/C=AT/O=Test/OU=Testcontainer/CN=rootCA" | ||
SERVER_SUBJECT="/C=AT/O=Test/OU=Testcontainer/CN=ldap.example.org" | ||
|
||
# Create directory for certificates | ||
mkdir -p certs | ||
rm -fr certs/* | ||
cd certs | ||
|
||
# Create a config file for the server certificate | ||
cat >server.cnf <<EOF | ||
[req] | ||
distinguished_name = req_distinguished_name | ||
x509_extensions = v3_req | ||
prompt = no | ||
[req_distinguished_name] | ||
C = AT | ||
O = Test | ||
OU = Testcontainer | ||
CN = ldap.example.org | ||
[v3_req] | ||
keyUsage = critical, digitalSignature, keyEncipherment | ||
extendedKeyUsage = serverAuth | ||
subjectAltName = @alt_names | ||
[alt_names] | ||
DNS.1 = localhost | ||
DNS.2 = openldap | ||
EOF | ||
|
||
# Create a self-signed root certificate | ||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout rootCA.key -out rootCA.crt -subj "$ROOT_SUBJECT" | ||
|
||
# Create a key for the server certificate | ||
openssl genrsa -out ldap.example.org.key 2048 | ||
|
||
# Generate Server CSR using the config file | ||
openssl req -new -key ldap.example.org.key -out ldap.example.org.csr -subj "$SERVER_SUBJECT" | ||
|
||
# Sign the server certificate with the Root CA | ||
openssl x509 -req -in ldap.example.org.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out ldap.example.org.crt -days 365 -extfile server.cnf -extensions v3_req | ||
|
||
# Clean up | ||
rm -r *.csr *.cnf *.srl rootCA.key | ||
|
||
cd - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters