本文整理汇总了Golang中golang.org/x/crypto/ssh.Certificate.Serial方法的典型用法代码示例。如果您正苦于以下问题:Golang Certificate.Serial方法的具体用法?Golang Certificate.Serial怎么用?Golang Certificate.Serial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类golang.org/x/crypto/ssh.Certificate
的用法示例。
在下文中一共展示了Certificate.Serial方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: saveSigningRequest
func (h *certRequestHandler) saveSigningRequest(config ssh_ca_util.SignerdConfig, environment, reason, requestIDStr string, requestSerial uint64, cert *ssh.Certificate) (bool, error) {
requesterFp := ssh_ca_util.MakeFingerprint(cert.SignatureKey.Marshal())
maxValidBefore := uint64(time.Now().Add(time.Duration(config.MaxCertLifetime) * time.Second).Unix())
if config.MaxCertLifetime != 0 && cert.ValidBefore > maxValidBefore {
return false, fmt.Errorf("Certificate is valid longer than maximum permitted by configuration %d > %d",
cert.ValidBefore, maxValidBefore)
}
// We override keyid here so that its a server controlled value. Instead of
// letting a requester attempt to spoof it.
var ok bool
cert.KeyId, ok = config.AuthorizedUsers[requesterFp]
if !ok {
return false, fmt.Errorf("Requester fingerprint (%s) not found in config", requesterFp)
}
if requestSerial == 0 {
return false, fmt.Errorf("Serial number not set.")
}
cert.Serial = requestSerial
certRequest := newcertRequest()
certRequest.request = cert
if environment == "" {
return false, fmt.Errorf("Environment is a required field")
}
certRequest.environment = environment
if reason == "" {
return false, fmt.Errorf("Reason is a required field")
}
certRequest.reason = reason
if len(requestIDStr) < 12 {
return false, fmt.Errorf("Request id is too short to be useful.")
}
_, ok = h.state[requestIDStr]
if ok {
return false, fmt.Errorf("Request id '%s' already in use.", requestIDStr)
}
h.state[requestIDStr] = certRequest
// This is the special case of supporting auto-signing.
if config.NumberSignersRequired < 0 {
signed, err := h.maybeSignWithCa(requestIDStr, config.NumberSignersRequired, config.SigningKeyFingerprint)
if signed && err == nil {
return true, nil
}
}
return false, nil
}
示例2: saveSigningRequest
func (h *certRequestHandler) saveSigningRequest(config ssh_ca_util.SignerdConfig, environment, reason, requestIDStr string, requestSerial uint64, cert *ssh.Certificate) error {
requesterFp := ssh_ca_util.MakeFingerprint(cert.SignatureKey.Marshal())
// We override keyid here so that its a server controlled value. Instead of
// letting a requester attempt to spoof it.
var ok bool
cert.KeyId, ok = config.AuthorizedUsers[requesterFp]
if !ok {
return fmt.Errorf("Requester fingerprint (%s) not found in config", requesterFp)
}
if requestSerial == 0 {
return fmt.Errorf("Serial number not set.")
}
cert.Serial = requestSerial
certRequest := newcertRequest()
certRequest.request = cert
if environment == "" {
return fmt.Errorf("Environment is a required field")
}
certRequest.environment = environment
if reason == "" {
return fmt.Errorf("Reason is a required field")
}
certRequest.reason = reason
if len(requestIDStr) < 12 {
return fmt.Errorf("Request id is too short to be useful.")
}
_, ok = h.state[requestIDStr]
if ok {
return fmt.Errorf("Request id '%s' already in use.", requestIDStr)
}
h.state[requestIDStr] = certRequest
return nil
}