Back to Keycloak

Keycloak Arquillian Integration Testsuite

testsuite/integration-arquillian/servers/auth-server/common/pki/README.md

26.6.12.0 KB
Original Source

Keycloak Arquillian Integration Testsuite

This directory contains a OpenSSL CA and Intermediate CA that can be used to manage certificates.

Passwords

Passwords for any key file is password.

Steps to create a client certificate

In the instructions below, you may usually need to create your own files for private key, CSR request, certificate , p12 and also possibly custom openssl configuration. For the instructions below, replace the file names according your needs (For example replace [email protected] with something like [email protected] )

Create a private key for the client

openssl genrsa -aes256 -out certs/clients/test-[email protected] 4096 chmod 400 certs/clients/test-[email protected]

Create a CSR for the client

openssl req -config intermediate/openssl.cnf -key certs/clients/test-[email protected] -new -sha256 -out certs/clients/test-[email protected]

If you want to generate a CSR with extensions you can use a command similar to the following:

openssl req -config intermediate/openssl-san.cnf -key certs/clients/test-[email protected] -new -sha256 -out certs/clients/test-[email protected]

Create a certificate using the CSR

openssl ca -config intermediate/openssl.cnf -extensions usr_cert -days 375 -notext -md sha256 -in certs/clients/test-[email protected] -out certs/clients/test-[email protected]

chmod 444 certs/clients/test-[email protected]

Verify the certificate

openssl x509 -noout -text -in certs/clients/test-[email protected]

Check if certificate has a valid chain of trust

openssl verify -CAfile intermediate/certs/ca-chain.cert.pem certs/clients/test-[email protected]

Transform both certificate and private key to PKCS12 format

openssl pkcs12 -export -in certs/clients/test-[email protected] -inkey certs/clients/test-[email protected] -out certs/clients/[email protected] -name test-user -CAfile intermediate/certs/ca-chain.cert.pem