service.go 666 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. // NewService returns a new Service type.
  14. func NewService(_ context.Context, opts Options) (*Service, error) {
  15. if err := opts.Validate(); err != nil {
  16. return nil, err
  17. }
  18. // TODO: should this become similar to the New CertificateAuthorityService as in x509CAService?
  19. return &Service{
  20. certificateChain: opts.CertificateChain,
  21. signer: opts.Signer,
  22. decrypter: opts.Decrypter,
  23. }, nil
  24. }