forked from TrueCloudLab/certificates
Cherry-pick acme.go from acdfdf3
This commit is contained in:
parent
2505a68f69
commit
ee7307bd41
1 changed files with 35 additions and 0 deletions
|
@ -3,6 +3,7 @@ package provisioner
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -98,6 +99,10 @@ type ACME struct {
|
||||||
Claims *Claims `json:"claims,omitempty"`
|
Claims *Claims `json:"claims,omitempty"`
|
||||||
Options *Options `json:"options,omitempty"`
|
Options *Options `json:"options,omitempty"`
|
||||||
|
|
||||||
|
// TODO(hs): WIP configuration for ACME Device Attestation
|
||||||
|
AttestationRoots []byte `json:"attestationRoots"`
|
||||||
|
attestationRootPool *x509.CertPool
|
||||||
|
|
||||||
ctl *Controller
|
ctl *Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +160,7 @@ func (p *ACME) Init(config Config) (err error) {
|
||||||
return errors.New("provisioner name cannot be empty")
|
return errors.New("provisioner name cannot be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
for _, c := range p.Challenges {
|
for _, c := range p.Challenges {
|
||||||
if err := c.Validate(); err != nil {
|
if err := c.Validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -166,6 +172,29 @@ func (p *ACME) Init(config Config) (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=======
|
||||||
|
// TODO(hs): WIP configuration for ACME Device Attestation
|
||||||
|
p.attestationRootPool = x509.NewCertPool()
|
||||||
|
|
||||||
|
var (
|
||||||
|
block *pem.Block
|
||||||
|
rest = p.AttestationRoots
|
||||||
|
)
|
||||||
|
for rest != nil {
|
||||||
|
block, rest = pem.Decode(rest)
|
||||||
|
if block == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
cert, err := x509.ParseCertificate(block.Bytes)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "error parsing x509 certificate from PEM block")
|
||||||
|
}
|
||||||
|
p.attestationRootPool.AddCert(cert)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(hs): need validation for number of certs? The current ones are only for the `tpm` type; not for Apple or Yubico.
|
||||||
|
|
||||||
|
>>>>>>> acdfdf34 (Add `tpm` attestation with configurable roots)
|
||||||
p.ctl, err = NewController(p, p.Claims, config, p.Options)
|
p.ctl, err = NewController(p, p.Claims, config, p.Options)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -282,3 +311,9 @@ func (p *ACME) IsAttestationFormatEnabled(ctx context.Context, format ACMEAttest
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(hs): we may not want to expose the root pool like this;
|
||||||
|
// call into an interface function instead to authorize?
|
||||||
|
func (p *ACME) GetAttestationRoots() (*x509.CertPool, error) {
|
||||||
|
return p.attestationRootPool, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue