fix(storage): store private keys for all certificates, not just CAs

main
stef 2025-12-07 09:47:07 +01:00
parent 1c02d6a4ab
commit 98adf5e971
1 changed files with 3 additions and 3 deletions

View File

@ -28,7 +28,7 @@ type CertificateDoc struct {
IsCA bool `bson:"is_ca"` IsCA bool `bson:"is_ca"`
Revoked bool `bson:"revoked"` Revoked bool `bson:"revoked"`
Cert string `bson:"cert"` // Base64 encoded certificate Cert string `bson:"cert"` // Base64 encoded certificate
PrivateKey string `bson:"private_key"` // Base64 encoded private key (only for CAs) PrivateKey string `bson:"private_key"` // Base64 encoded private key (for all certificates)
CreatedAt time.Time `bson:"created_at"` CreatedAt time.Time `bson:"created_at"`
} }
@ -87,8 +87,8 @@ func (m *MongoStore) SaveCertificate(id string, cert *pki.Certificate) error {
doc.Cert = base64.StdEncoding.EncodeToString(cert.Cert.Raw) doc.Cert = base64.StdEncoding.EncodeToString(cert.Cert.Raw)
} }
// Encoder la clé privée en base64 (seulement pour les CAs) // Encoder la clé privée en base64 (pour tous les certificats)
if cert.PrivateKey != nil && cert.IsCA { if cert.PrivateKey != nil {
privKeyBytes, err := marshalPrivateKey(cert.PrivateKey) privKeyBytes, err := marshalPrivateKey(cert.PrivateKey)
if err != nil { if err != nil {
return err return err