Skip to content

Commit

Permalink
fix: use base64-encoded env variable (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
hydra-yse authored Dec 20, 2024
1 parent 73fea1f commit 0a9c0fc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"crypto/x509"
"encoding/base64"
"encoding/pem"
"log"

Expand All @@ -13,7 +14,12 @@ type Certificate struct {
}

func (c *Certificate) UnmarshalEnvironmentValue(data string) error {
CACertBlock, _ := pem.Decode([]byte(data))
decodedData, err := base64.StdEncoding.DecodeString(data)
if err != nil {
log.Fatal("Could not decode base64-encoded certificate:", err)
}

CACertBlock, _ := pem.Decode(decodedData)
if CACertBlock == nil {
log.Fatal("CA certificate is invalid")
}
Expand Down

0 comments on commit 0a9c0fc

Please sign in to comment.