Review fixes pt. 2

This commit is contained in:
Roland Shoemaker 2015-11-25 12:56:44 -08:00
parent 427063141d
commit 52b7effa5d
4 changed files with 21 additions and 50 deletions

View File

@ -6,7 +6,6 @@
package main
import (
"fmt"
"os"
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cactus/go-statsd-client/statsd"
@ -27,8 +26,7 @@ func main() {
logs := make([]*publisher.Log, len(c.Common.CT.Logs))
var err error
for i, ld := range c.Common.CT.Logs {
fmt.Println(ld)
logs[i], err = publisher.NewLog(ld.URI, ld.PublicKey)
logs[i], err = publisher.NewLog(ld.URI, ld.Key)
cmd.FailOnError(err, "Unable to parse CT log description")
}

View File

@ -389,8 +389,9 @@ func (d *ConfigDuration) UnmarshalYAML(unmarshal func(interface{}) error) error
return nil
}
// LogDescription something something
// LogDescription contains the information needed to submit certificates
// to a CT log and verify returned receipts
type LogDescription struct {
URI string `json:"uri"`
PublicKey string `json:"key"`
URI string
Key string
}

View File

@ -6,7 +6,6 @@
package core
import (
"bytes"
"crypto/subtle"
"crypto/x509"
"encoding/base64"
@ -16,7 +15,6 @@ import (
"strings"
"time"
ct "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/google/certificate-transparency/go"
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/letsencrypt/go-jose"
)
@ -771,41 +769,6 @@ type SignedCertificateTimestamp struct {
LockCol int64
}
// InternalToSCT converts a internal SCT object to a google SCT object
func InternalToSCT(iSCT SignedCertificateTimestamp) (*ct.SignedCertificateTimestamp, error) {
sig, err := ct.UnmarshalDigitallySigned(bytes.NewReader(iSCT.Signature))
if err != nil {
return nil, err
}
sct := &ct.SignedCertificateTimestamp{
SCTVersion: ct.Version(iSCT.SCTVersion),
Timestamp: iSCT.Timestamp,
Extensions: ct.CTExtensions(iSCT.Extensions),
Signature: *sig,
}
err = sct.LogID.FromBase64String(iSCT.LogID)
if err != nil {
return nil, err
}
return sct, nil
}
// SCTToInternal converts a google SCT object to a internal SCT object
func SCTToInternal(sct *ct.SignedCertificateTimestamp, serial string) (SignedCertificateTimestamp, error) {
sig, err := ct.MarshalDigitallySigned(sct.Signature)
if err != nil {
return SignedCertificateTimestamp{}, err
}
return SignedCertificateTimestamp{
CertificateSerial: serial,
SCTVersion: uint8(sct.SCTVersion),
LogID: sct.LogID.Base64String(),
Timestamp: sct.Timestamp,
Extensions: sct.Extensions,
Signature: sig,
}, nil
}
// RevocationCode is used to specify a certificate revocation reason
type RevocationCode int

View File

@ -25,12 +25,6 @@ type Log struct {
Verifier *ct.SignatureVerifier
}
// LogDescription something something
type LogDescription struct {
URI string `json:"uri"`
PublicKey string `json:"key"`
}
// NewLog returns a initialized Log struct
func NewLog(uri, b64PK string) (*Log, error) {
var l Log
@ -113,7 +107,7 @@ func (pub *PublisherImpl) SubmitToCT(der []byte) error {
continue
}
internalSCT, err := core.SCTToInternal(sct, core.SerialToString(cert.SerialNumber))
internalSCT, err := sctToInternal(sct, core.SerialToString(cert.SerialNumber))
if err != nil {
// AUDIT[ Error Conditions ] 9cc4d537-8534-4970-8665-4b382abe82f3
pub.log.Audit(fmt.Sprintf("Failed to convert SCT receipt: %s", err))
@ -130,3 +124,18 @@ func (pub *PublisherImpl) SubmitToCT(der []byte) error {
return nil
}
func sctToInternal(sct *ct.SignedCertificateTimestamp, serial string) (core.SignedCertificateTimestamp, error) {
sig, err := ct.MarshalDigitallySigned(sct.Signature)
if err != nil {
return core.SignedCertificateTimestamp{}, err
}
return core.SignedCertificateTimestamp{
CertificateSerial: serial,
SCTVersion: uint8(sct.SCTVersion),
LogID: sct.LogID.Base64String(),
Timestamp: sct.Timestamp,
Extensions: sct.Extensions,
Signature: sig,
}, nil
}