Add generate server cert and add ssl for application

main
Sambo Chea 2 months ago
parent f6c0a31fc1
commit 83bc97bb02
Signed by: sombochea
GPG Key ID: 3C7CF22A05D95490
  1. 2
      api/src/main/resources/application-demo.yml
  2. 10
      api/src/main/resources/application.yml
  3. BIN
      api/src/main/resources/keystore/server.jks
  4. BIN
      api/src/main/resources/keystore/server.p12
  5. 18
      generate-server-cert.sh

@ -1,2 +0,0 @@
server:
port: ${APP_PORT:8080}

@ -1,3 +1,13 @@
server:
port: ${SERVER_PORT:8080}
ssl:
key-store: ${SERVER_SSL_KEY_STORE:classpath:keystore/server.jks}
key-store-password: ${SERVER_SSL_KEY_STORE_PASSWORD:cubetiq}
key-password: ${SERVER_SSL_KEY_PASSWORD:cubetiq}
enabled: ${SERVER_SSL_ENABLED:true}
compression:
enabled: ${SERVER_COMPRESSION_ENABLED:${server.ssl.enabled}}
spring:
profiles:
active: ${APP_PROFILE:demo}

@ -0,0 +1,18 @@
#!/bin/sh -e
CERT_NAME="${1:-server}"
CERT_SIZE="${2:-2048}"
CERT_DAYS="${3:-3650}"
DEST_DIR="${4:-./}"
echo "Create directory ${DEST_DIR}"
mkdir -p "${DEST_DIR}"
echo "Generating server keystore ${CERT_NAME}.p12 with size: ${CERT_SIZE} days: ${CERT_DAYS}"
keytool -genkeypair -alias ${CERT_NAME} -keyalg RSA -keysize ${CERT_SIZE} -storetype PKCS12 -keystore ${DEST_DIR}${CERT_NAME}.p12 -validity ${CERT_DAYS}
echo "Generating server keystore ${CERT_NAME}.jks with size: ${CERT_SIZE} days: ${CERT_DAYS}"
keytool -genkeypair -alias ${CERT_NAME} -keyalg RSA -keysize ${CERT_SIZE} -keystore ${DEST_DIR}${CERT_NAME}.jks -validity ${CERT_DAYS}
echo "Import keystore ${CERT_NAME}.jks into ${CERT_NAME}.p12"
keytool -importkeystore -srckeystore ${DEST_DIR}${CERT_NAME}.jks -destkeystore ${DEST_DIR}${CERT_NAME}.p12 -deststoretype pkcs12
Loading…
Cancel
Save