mirror of
https://github.com/truenas/charts.git
synced 2026-06-16 23:19:15 +08:00
fail if cert is revoked or expired
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
{{- $certName := "TODO: Get the certName" -}}
|
||||
|
||||
{{- if include "ix.v1.common.certificate.exists" (dict "root" $root "certName" $certName) }}
|
||||
{{- if (include "ix.v1.common.certificate.exists" (dict "root" $root "certName" $certName)) }}
|
||||
---
|
||||
apiVersion: {{ include "ix.v1.common.capabilities.secret.apiVersion" . }}
|
||||
kind: Secret
|
||||
@@ -22,7 +22,7 @@ metadata:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
tls.crt:
|
||||
tls.key:
|
||||
tls.crt: {{ include "ix.v1.common.certificate.get" (dict "root" $root "certName" $certName "key" "certificate") }}
|
||||
tls.key: {{ include "ix.v1.common.certificate.get" (dict "root" $root "certName" $certName "key" "privatekey") }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -11,29 +11,28 @@ This checks that the certName exists as a key/dict.
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Returns the certificate
|
||||
Returns any key (based on the .key value)
|
||||
Example keys (certificate, privatekey, expired, revoked)
|
||||
*/}}
|
||||
{{- define "ix.v1.common.certificate.cert" -}}
|
||||
{{- define "ix.v1.common.certificate.get" -}}
|
||||
{{- $certName := .certName -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $key := .key -}}
|
||||
|
||||
{{- if (include "ix.v1.common.certificate.exists" (dict "root" $root "certName" $certName)) -}}
|
||||
{{- $certificate := (get $root.Values.ixCertificates (toString $certName)) -}}
|
||||
{{- $certificate.certificate -}}
|
||||
{{- if eq (get $certificate "revoked") "true" -}}
|
||||
{{- fail (printf "Certificate (%s) has been revoked." $certName) -}}
|
||||
{{- end -}}
|
||||
{{- if eq (get $certificate "expired") "true" -}}
|
||||
{{- fail (printf "Certificate (%s) has been expired." $certName) -}}
|
||||
{{- end -}}
|
||||
{{- if (hasKey $certificate "key") -}}
|
||||
{{- get $certificate "key" -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "Key (%s) does not exist in certificate (%s)" $key $certName) -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{ fail (printf "Certificate (%s) did not found." $certName) }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Returns the privateKey
|
||||
*/}}
|
||||
{{- define "ix.v1.common.certificate.privatekey" -}}
|
||||
{{- $certName := .certName -}}
|
||||
{{- $root := .root -}}
|
||||
{{- if (include "ix.v1.common.certificate.exists" (dict "root" $root "certName" $certName)) -}}
|
||||
{{- $privateKey := (get $root.Values.ixCertificates (toString $certName)) -}}
|
||||
{{- $privateKey.privatekey -}}
|
||||
{{- else -}}
|
||||
{{ fail (printf "Certificate (%s) did not found." $certName) }}
|
||||
{{- fail (printf "Certificate (%s) did not found." $certName) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user