4
0

service.go 627 B

12345678910111213141516171819202122232425262728
  1. package scep
  2. import (
  3. "context"
  4. "crypto"
  5. "crypto/x509"
  6. )
  7. // Service is a wrapper for crypto.Signer and crypto.Decrypter
  8. type Service struct {
  9. certificateChain []*x509.Certificate
  10. signer crypto.Signer
  11. decrypter crypto.Decrypter
  12. }
  13. func NewService(ctx context.Context, opts Options) (*Service, error) {
  14. if err := opts.Validate(); err != nil {
  15. return nil, err
  16. }
  17. // TODO: should this become similar to the New CertificateAuthorityService as in x509CAService?
  18. return &Service{
  19. certificateChain: opts.CertificateChain,
  20. signer: opts.Signer,
  21. decrypter: opts.Decrypter,
  22. }, nil
  23. }