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"
|
"crypto/x509"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParseCert parses the x509 certificate from a PEM-encoded value.
|
// 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())
|
h.Write(pub.Y.Bytes())
|
||||||
return h.Sum([]byte{}), nil
|
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
|
// Set the response
|
||||||
*reply = structs.IssuedCert{
|
*reply = structs.IssuedCert{
|
||||||
SerialNumber: template.SerialNumber,
|
SerialNumber: connect.HexString(template.SerialNumber.Bytes()),
|
||||||
CertPEM: buf.String(),
|
CertPEM: buf.String(),
|
||||||
Service: serviceId.Service,
|
Service: serviceId.Service,
|
||||||
ServiceURI: template.URIs[0].String(),
|
ServiceURI: template.URIs[0].String(),
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package structs
|
package structs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/big"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -71,7 +70,8 @@ func (q *CASignRequest) RequestDatacenter() string {
|
||||||
// IssuedCert is a certificate that has been issued by a Connect CA.
|
// IssuedCert is a certificate that has been issued by a Connect CA.
|
||||||
type IssuedCert struct {
|
type IssuedCert struct {
|
||||||
// SerialNumber is the unique serial number for this certificate.
|
// 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
|
// CertPEM and PrivateKeyPEM are the PEM-encoded certificate and private
|
||||||
// key for that cert, respectively. This should not be stored in the
|
// key for that cert, respectively. This should not be stored in the
|
||||||
|
|
Loading…
Reference in New Issue