本文整理匯總了Golang中github.com/google/certificate-transparency/go/client.LogClient.AddChain方法的典型用法代碼示例。如果您正苦於以下問題:Golang LogClient.AddChain方法的具體用法?Golang LogClient.AddChain怎麽用?Golang LogClient.AddChain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/certificate-transparency/go/client.LogClient
的用法示例。
在下文中一共展示了LogClient.AddChain方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: addChain
func addChain(logClient *client.LogClient) {
if *certChain == "" {
log.Fatalf("No certificate chain file specified with -cert_chain")
}
rest, err := ioutil.ReadFile(*certChain)
if err != nil {
log.Fatalf("Failed to read certificate file: %v", err)
}
var chain []ct.ASN1Cert
for {
var block *pem.Block
block, rest = pem.Decode(rest)
if block == nil {
break
}
if block.Type == "CERTIFICATE" {
chain = append(chain, ct.ASN1Cert(block.Bytes))
}
}
sct, err := logClient.AddChain(chain)
if err != nil {
log.Fatal(err)
}
// Display the SCT
when := ctTimestampToTime(sct.Timestamp)
fmt.Printf("%v: Uploaded chain of %d certs to %v log at %v\n", when, len(chain), sct.SCTVersion, *logURI)
fmt.Printf("%v\n", signatureToString(&sct.Signature))
}
示例2: certSubmitterJob
func certSubmitterJob(ctx context.Context, addedCerts chan<- *preload.AddedCert, log_client *client.LogClient, certs <-chan *ct.LogEntry,
wg *sync.WaitGroup) {
for c := range certs {
chain := make([]ct.ASN1Cert, len(c.Chain)+1)
chain[0] = c.X509Cert.Raw
copy(chain[1:], c.Chain)
sct, err := log_client.AddChain(ctx, chain)
if err != nil {
log.Printf("failed to add chain with CN %s: %v\n", c.X509Cert.Subject.CommonName, err)
recordFailure(addedCerts, chain[0], err)
continue
}
recordSct(addedCerts, chain[0], sct)
if !*quiet {
log.Printf("Added chain for CN '%s', SCT: %s\n", c.X509Cert.Subject.CommonName, sct)
}
}
wg.Done()
}