-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openldap): tls certs and ldif file (#217)
Support the operations ``` with_ldif_file(...) with_certs(...) ``` on the OpenLdap Container
- Loading branch information
Showing
4 changed files
with
293 additions
and
2 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,17 @@ | ||
# OpenLDAP Testcontainer | ||
|
||
This modules provides the `bitnami/openldap` image as a testcontainer. | ||
|
||
|
||
## Testing | ||
|
||
For testing tls connections, you need to provide a certificate and key. All needed tls artifacts are generated by the `generate-certs.sh` script. | ||
|
||
The used openssl version for the latests created certificate is: | ||
|
||
```bash | ||
> openssl version | ||
OpenSSL 3.0.13 30 Jan 2024 (Library: OpenSSL 3.0.13 30 Jan 2024) | ||
``` | ||
|
||
Please update the version here in the README if you generate new certificates for the tests. |
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,53 @@ | ||
#!/bin/bash | ||
|
||
## Helper Script for creating certificates for the LDAP server tls tests | ||
|
||
# Set variables | ||
ROOT_SUBJECT="/C=AT/O=Test/OU=Testcontainer/CN=rootCA" | ||
SERVER_SUBJECT="/C=AT/O=Test/OU=Testcontainer/CN=ldap.example.org" | ||
DAYS_UNTIL_EXPIRE=$((365 * 20)) | ||
|
||
# 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 $DAYS_UNTIL_EXPIRE -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 $DAYS_UNTIL_EXPIRE -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