Skip to content

Commit 3e31aad

Browse files
enable credhub certificate hot reload
Co-authored-by: Pavel Busko <pavel.busko@sap.com>
1 parent e429b60 commit 3e31aad

9 files changed

Lines changed: 89 additions & 32 deletions

File tree

certs/all-in-one.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ DNS.11 = log-api
3535
DNS.12 = log-cache
3636
DNS.13 = log_cache
3737
DNS.14 = reverse-log-proxy
38+
DNS.15 = credhub
3839

3940
IP.1 = 127.0.0.1

docker-bake.hcl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,14 @@ variable "CREDHUB_RELEASE_VERSION" {
210210
}
211211

212212
target "credhub" {
213+
dockerfile = "releases/credhub/credhub.Dockerfile"
214+
213215
tags = [ "${REGISTRY_PREFIX}credhub:latest", "${REGISTRY_PREFIX}credhub:${CREDHUB_RELEASE_VERSION}" ]
214216

215-
context = "https://github.com/pivotal/credhub-release.git#${CREDHUB_RELEASE_VERSION}:src/credhub"
217+
contexts = {
218+
src = "https://github.com/pivotal/credhub-release.git#${CREDHUB_RELEASE_VERSION}:src/credhub"
219+
"files" = "releases/credhub/files"
220+
}
216221
}
217222

218223
variable "CFLINUXFS4_VERSION" {

helmfile.yaml.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ releases:
253253
- postgresql
254254
values:
255255
- dbPassword: {{ .Values.secrets.dbPassword }}
256-
- caCertificateSecret: instance-identity
256+
- certificateSecret: all-in-one-tls
257257

258258
- name: locket
259259
namespace: default
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Build image
2+
FROM --platform=$BUILDPLATFORM bellsoft/liberica-openjdk-debian:21 AS builder
3+
4+
WORKDIR /app
5+
COPY --from=src . .
6+
7+
RUN ./gradlew bootJar -x test -x check
8+
9+
# Runtime image
10+
FROM bellsoft/liberica-openjre-debian:21
11+
12+
WORKDIR /app
13+
14+
COPY --from=files --chmod=0755 /entrypoint.sh /entrypoint.sh
15+
COPY --from=builder /app/applications/credhub-api/build/libs/credhub.jar .
16+
17+
EXPOSE 9000
18+
ENTRYPOINT ["/entrypoint.sh"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
APPLICATION_YAML=${APPLICATION_YAML:-/application.yml}
4+
5+
if [ ! -f "/ssl/trust_store.jks" ]; then
6+
echo "Creating trust store from CA certificate"
7+
keytool -import -noprompt -trustcacerts -alias uaa_ca -file /ssl/ca.crt -keystore /tmp/trust_store.jks -storepass ${TRUST_STORE_PASSWORD}
8+
export TRUST_STORE_PATH=/tmp/trust_store.jks
9+
fi
10+
11+
JAVA_OPTS="-Djava.security.egd=file:/dev/urandom"
12+
JAVA_OPTS="$JAVA_OPTS -Djdk.tls.ephemeralDHKeySize=4096"
13+
JAVA_OPTS="$JAVA_OPTS -Djdk.tls.namedGroups=\"secp384r1\""
14+
JAVA_OPTS="$JAVA_OPTS -Djavax.net.ssl.trustStore=${TRUST_STORE_PATH}"
15+
JAVA_OPTS="$JAVA_OPTS -Djavax.net.ssl.trustStorePassword=${TRUST_STORE_PASSWORD}"
16+
JAVA_OPTS="$JAVA_OPTS -Dspring.config.location=${APPLICATION_YAML}"
17+
18+
trap 'kill -TERM "$java_pid"' TERM INT
19+
20+
java $JAVA_OPTS -ea -jar /app/credhub.jar --management.server.port=9001 &
21+
java_pid=$!
22+
23+
wait "$java_pid"

releases/credhub/helm/files/credhub.yaml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{{ $_ := required ".Values.dbPassword must be provided" .Values.dbPassword }}
22
auth-server:
33
url: {{ .Values.uaa.address }}
4-
trust_store: /app/stores/trust_store.jks
5-
trust_store_password: changeit
4+
trust_store: ${TRUST_STORE_PATH}
5+
trust_store_password: ${TRUST_STORE_PASSWORD}
66
encryption:
77
key_creation_enabled: true
88
providers:
@@ -46,17 +46,34 @@ server:
4646
port: 8844
4747
ssl:
4848
enabled: true
49-
key_store: /app/stores/key_store.jks
50-
key_store_password: changeit
51-
key_password: changeit
52-
key_alias: cert
49+
bundle: credhub
5350
ciphers: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384
5451
client_auth: want
55-
trust_store: /app/stores/trust_store.jks
56-
trust_store_password: changeit
57-
trust_store_type: JKS
5852
enabled_protocols: TLSv1.2,TLSv1.3
53+
tomcat:
54+
accesslog:
55+
enabled: true
56+
pattern: '%h %l %u %t "%r" %s %b %D'
57+
directory: /dev
58+
prefix: stdout
59+
suffix:
60+
file-date-format:
61+
buffered: false
62+
rotate: false
5963
spring:
64+
ssl:
65+
bundle:
66+
pem:
67+
credhub:
68+
reload-on-update: true
69+
keystore:
70+
certificate: file:/ssl/tls.crt
71+
private-key: file:/ssl/tls.key
72+
truststore:
73+
certificate: file:/ssl/ca.crt
74+
watch:
75+
file:
76+
quiet-period: 1s
6077
flyway:
6178
enabled: true
6279
locations:

releases/credhub/helm/templates/credhub.yaml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,16 @@ spec:
3636
env:
3737
- name: TRUST_STORE_PASSWORD
3838
value: changeit
39-
- name: KEY_STORE_PASSWORD
40-
value: changeit
41-
- name: ENCRYPTION_PASSWORD
42-
value: changeit
43-
- name: SERVER_CA_PRIVATE_KEY_PATH
44-
value: /etc/ssl/ca/tls.key
45-
- name: SERVER_CA_CERT_PATH
46-
value: /etc/ssl/ca/tls.crt
47-
- name: UAA_CA_PATH
48-
value: /etc/ssl/ca/tls.crt
49-
- name: UAA_URL
50-
value: https://uaa.{{ .Release.Namespace }}.svc.cluster.local
51-
- name: SUBJECT_ALTERNATIVE_NAMES
52-
value: "DNS:{{ .Values.hostname }},DNS:credhub.{{ .Release.Namespace }}.svc.cluster.local,DNS:credhub.{{ .Release.Namespace }}.svc,DNS:credhub.{{ .Release.Namespace }},DNS:credhub"
39+
- name: TRUST_STORE_PATH
40+
value: /ssl/trust_store.jks
5341
volumeMounts:
5442
- name: config
55-
mountPath: /app/config
56-
- name: ca
57-
mountPath: /etc/ssl/ca
43+
mountPath: /application.yml
44+
subPath: application.yml
45+
- name: ssl
46+
mountPath: /ssl
47+
- name: tmp
48+
mountPath: /tmp
5849
{{- if .Values.nodeSelector }}
5950
nodeSelector:
6051
{{- toYaml .Values.nodeSelector | nindent 8 }}
@@ -67,9 +58,11 @@ spec:
6758
- name: config
6859
configMap:
6960
name: credhub-config
70-
- name: ca
61+
- name: tmp
62+
emptyDir: {}
63+
- name: ssl
7164
secret:
72-
secretName: {{ required "caCertificateSecret is required" .Values.caCertificateSecret }}
65+
secretName: {{ required "certificateSecret is required" .Values.certificateSecret }}
7366
---
7467
apiVersion: v1
7568
kind: Service

releases/credhub/helm/values.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"additionalProperties": false,
44
"properties": {
5-
"caCertificateSecret": {
5+
"certificateSecret": {
66
"type": "string"
77
},
88
"dbPassword": {

releases/credhub/helm/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ tolerations: ~
1212

1313
dbPassword: ~
1414

15-
caCertificateSecret: ""
15+
certificateSecret: ""

0 commit comments

Comments
 (0)