本文整理汇总了Golang中github.com/letsencrypt/boulder/rpc.RegistrationAuthorityClient.AdministrativelyRevokeCertificate方法的典型用法代码示例。如果您正苦于以下问题:Golang RegistrationAuthorityClient.AdministrativelyRevokeCertificate方法的具体用法?Golang RegistrationAuthorityClient.AdministrativelyRevokeCertificate怎么用?Golang RegistrationAuthorityClient.AdministrativelyRevokeCertificate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/letsencrypt/boulder/rpc.RegistrationAuthorityClient
的用法示例。
在下文中一共展示了RegistrationAuthorityClient.AdministrativelyRevokeCertificate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: revokeBySerial
func revokeBySerial(serial string, reasonCode core.RevocationCode, deny bool, rac rpc.RegistrationAuthorityClient, auditlogger *blog.AuditLogger, tx *gorp.Transaction) (err error) {
if reasonCode < 0 || reasonCode == 7 || reasonCode > 10 {
panic(fmt.Sprintf("Invalid reason code: %d", reasonCode))
}
certObj, err := tx.Get(core.Certificate{}, serial)
if err != nil {
return
}
certificate, ok := certObj.(*core.Certificate)
if !ok {
err = fmt.Errorf("Cast failure")
return
}
cert, err := x509.ParseCertificate(certificate.DER)
if err != nil {
return
}
if deny {
// Retrieve DNS names associated with serial
err = addDeniedNames(tx, append(cert.DNSNames, cert.Subject.CommonName))
if err != nil {
return
}
}
u, err := user.Current()
err = rac.AdministrativelyRevokeCertificate(*cert, reasonCode, u.Username)
if err != nil {
return
}
auditlogger.Info(fmt.Sprintf("Revoked certificate %s with reason '%s'", serial, core.RevocationReasons[reasonCode]))
return
}
示例2: revokeBySerial
func revokeBySerial(ctx context.Context, serial string, reasonCode core.RevocationCode, rac rpc.RegistrationAuthorityClient, logger blog.Logger, tx *gorp.Transaction) (err error) {
if reasonCode < 0 || reasonCode == 7 || reasonCode > 10 {
panic(fmt.Sprintf("Invalid reason code: %d", reasonCode))
}
certObj, err := tx.Get(core.Certificate{}, serial)
if err != nil {
return
}
certificate, ok := certObj.(*core.Certificate)
if !ok {
err = fmt.Errorf("Cast failure")
return
}
cert, err := x509.ParseCertificate(certificate.DER)
if err != nil {
return
}
u, err := user.Current()
err = rac.AdministrativelyRevokeCertificate(ctx, *cert, reasonCode, u.Username)
if err != nil {
return
}
logger.Info(fmt.Sprintf("Revoked certificate %s with reason '%s'", serial, core.RevocationReasons[reasonCode]))
return
}