Skip to content

Conversation

@KeeyanGhoreshi
Copy link

Enables https through setting environment variables. If you're in intelliJ, use the run -> edit configurations menu option to set environment variables easily for local testing.

This will require a certificate, I use a self-signed jks cert using keytool for local testing.

To try this out, you will need to set the following environment variables:

EHR_SSL_ENABLED defaults to false, needs to be true to use https.
EHR_KEY_STORE_TYPE defaults to jks but can also be pkcs12 if using a PKCS12 keystore
EHR_KEY_STORE_PATH the path to the keystore file
EHR_KEY_STORE_PASSWORD the password for the keystore
EHR_KEY_PASSWORD the password for the key
EHR_KEY_ALIAS the alias of the key

Once all these env variables are set, the test-ehr should launch and you can make a request using https, albeit if you use a self-signed cert you will have to get past the warning telling you that the cert is self-signed.

I'll also note that I ran into some issues using a pkcs12 key. As far as I could tell, it was related to the version of java we're using. But I'm not 100% sure.

Copy link

@plarocque4 plarocque4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works great. I was able to get it to work by generating a keystore:
keytool -genkeypair -alias localhost -keyalg RSA -keysize 2048 -validity 365 -keystore server.keystore -dname "cn=Server Administrator,o=Acme,c=GB" -keypass secret -storepass secret

Then launching with:
EHR_SSL_ENABLED=true EHR_KEY_STORE_TYPE=jks EHR_KEY_STORE_PATH=/Users/plarocque/projects/rems/certs/server.keystore EHR_KEY_STORE_PASSWORD=secret EHR_KEY_PASSWORD=secret EHR_KEY_ALIAS=localhost gradle bootRun

@plarocque4 plarocque4 merged commit ad83c37 into dev Jul 28, 2023
@plarocque4 plarocque4 deleted the enable-https branch July 28, 2023 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants