agent/consul: encode issued cert serial number as hex encoded
This commit is contained in:
parent
deb55c436d
commit
2026cf3753
|
@ -7,6 +7,7 @@ import (
|
|||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ParseCert parses the x509 certificate from a PEM-encoded value.
|
||||
|
@ -72,3 +73,9 @@ func KeyId(raw interface{}) ([]byte, error) {
|
|||
h.Write(pub.Y.Bytes())
|
||||
return h.Sum([]byte{}), nil
|
||||
}
|
||||
|
||||
// HexString returns a standard colon-separated hex value for the input
|
||||
// byte slice. This should be used with cert serial numbers and so on.
|
||||
func HexString(input []byte) string {
|
||||
return strings.Replace(fmt.Sprintf("% x", input), " ", ":", -1)
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ func (s *ConnectCA) Sign(
|
|||
|
||||
// Set the response
|
||||
*reply = structs.IssuedCert{
|
||||
SerialNumber: template.SerialNumber,
|
||||
SerialNumber: connect.HexString(template.SerialNumber.Bytes()),
|
||||
CertPEM: buf.String(),
|
||||
Service: serviceId.Service,
|
||||
ServiceURI: template.URIs[0].String(),
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package structs
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -71,7 +70,8 @@ func (q *CASignRequest) RequestDatacenter() string {
|
|||
// IssuedCert is a certificate that has been issued by a Connect CA.
|
||||
type IssuedCert struct {
|
||||
// SerialNumber is the unique serial number for this certificate.
|
||||
SerialNumber *big.Int
|
||||
// This is encoded in standard hex separated by :.
|
||||
SerialNumber string
|
||||
|
||||
// CertPEM and PrivateKeyPEM are the PEM-encoded certificate and private
|
||||
// key for that cert, respectively. This should not be stored in the
|
||||
|
|
Loading…
Reference in New Issue