File: service.go

package info (click to toggle)
golang-github-smallstep-certificates 0.20.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,144 kB
  • sloc: sh: 278; makefile: 170
file content (28 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package scep

import (
	"context"
	"crypto"
	"crypto/x509"
)

// Service is a wrapper for crypto.Signer and crypto.Decrypter
type Service struct {
	certificateChain []*x509.Certificate
	signer           crypto.Signer
	decrypter        crypto.Decrypter
}

func NewService(ctx context.Context, opts Options) (*Service, error) {

	if err := opts.Validate(); err != nil {
		return nil, err
	}

	// TODO: should this become similar to the New CertificateAuthorityService as in x509CAService?
	return &Service{
		certificateChain: opts.CertificateChain,
		signer:           opts.Signer,
		decrypter:        opts.Decrypter,
	}, nil
}