vault/builtin/logical/pki/revocation/revocation_entry.go
Victor Rodriguez 67515c7e4a
Ongoing refactoring of PKI revocation code (#27427)
* Move resolveIssuerCRLPath to PKI issuing package.

* Move fetchCertBySerial to PKI issuing package.

* Move fetchRevocationInfo to PKI revocation package.

* Make associateRevokedCertWithIsssuer a method of RevocationInfo.

* Move serialFromCert and normalizeSerial to PKI parsing package.

* Move writeUnifiedRevocationEntry to PKI revocation package.

* Run make fmt.
2024-06-11 09:25:14 -04:00

35 lines
1.0 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package revocation
import (
"context"
"time"
"github.com/hashicorp/vault/builtin/logical/pki/issuing"
"github.com/hashicorp/vault/builtin/logical/pki/parsing"
"github.com/hashicorp/vault/sdk/logical"
)
type UnifiedRevocationEntry struct {
SerialNumber string `json:"-"`
CertExpiration time.Time `json:"certificate_expiration_utc"`
RevocationTimeUTC time.Time `json:"revocation_time_utc"`
CertificateIssuer issuing.IssuerID `json:"issuer_id"`
}
const (
UnifiedRevocationReadPathPrefix = "unified-revocation/"
UnifiedRevocationWritePathPrefix = UnifiedRevocationReadPathPrefix + "{{clusterId}}/"
)
func WriteUnifiedRevocationEntry(ctx context.Context, storage logical.Storage, ure *UnifiedRevocationEntry) error {
json, err := logical.StorageEntryJSON(UnifiedRevocationWritePathPrefix+parsing.NormalizeSerialForStorage(ure.SerialNumber), ure)
if err != nil {
return err
}
return storage.Put(ctx, json)
}