58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
|
package revoking
|
||
|
|
||
|
import (
|
||
|
"math/big"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type X509Revoking struct {
|
||
|
repository Repository
|
||
|
}
|
||
|
|
||
|
type RevokeCertificate struct {
|
||
|
serialNumber *big.Int
|
||
|
reason string
|
||
|
}
|
||
|
|
||
|
type CertificateRevoked struct {
|
||
|
serialNumber *big.Int
|
||
|
revocationTime time.Time
|
||
|
reason string
|
||
|
}
|
||
|
|
||
|
type CRLInformation struct{}
|
||
|
|
||
|
func (r *X509Revoking) Revoke(revokeCertificate *RevokeCertificate) (*CertificateRevoked, error) {
|
||
|
revoked := &CertificateRevoked{
|
||
|
serialNumber: revokeCertificate.serialNumber,
|
||
|
revocationTime: time.Now(),
|
||
|
reason: revokeCertificate.reason,
|
||
|
}
|
||
|
|
||
|
if err := r.repository.StoreRevocation(revoked); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return revoked, nil
|
||
|
}
|
||
|
|
||
|
func (r *X509Revoking) CreateCRL() (*CRLInformation, error) {
|
||
|
return &CRLInformation{}, nil
|
||
|
}
|
||
|
|
||
|
func (r *CertificateRevoked) SerialNumber() *big.Int {
|
||
|
return r.serialNumber
|
||
|
}
|
||
|
|
||
|
func (r *CertificateRevoked) RevocationTime() time.Time {
|
||
|
return r.revocationTime
|
||
|
}
|
||
|
|
||
|
func (r *CertificateRevoked) Reason() string {
|
||
|
return r.reason
|
||
|
}
|
||
|
|
||
|
func NewX509Revoking(repo Repository) *X509Revoking {
|
||
|
return &X509Revoking{repository: repo}
|
||
|
}
|