(requestID string, numSignersRequired int, signingKeyFingerprint string)
| 655 | } |
| 656 | |
| 657 | func (h *certRequestHandler) maybeSignWithCa(requestID string, numSignersRequired int, signingKeyFingerprint string) (bool, error) { |
| 658 | h.stateMutex.Lock() |
| 659 | defer h.stateMutex.Unlock() |
| 660 | if len(h.state[requestID].signatures) >= numSignersRequired { |
| 661 | if h.sshAgentConn == nil { |
| 662 | // This is used for testing. We're effectively disabling working |
| 663 | // with the ssh agent to avoid needing to mock it. |
| 664 | log.Print("ssh agent uninitialized, will not attempt signing. This is normal in unittests") |
| 665 | return true, nil |
| 666 | } |
| 667 | log.Printf("Received %d signatures for %s, signing now.\n", len(h.state[requestID].signatures), requestID) |
| 668 | signer, err := ssh_ca_util.GetSignerForFingerprintOrUrl(signingKeyFingerprint, h.sshAgentConn) |
| 669 | if err != nil { |
| 670 | log.Printf("Couldn't find signing key for request %s, unable to sign request: %s\n", requestID, err) |
| 671 | return false, fmt.Errorf("Couldn't find signing key, unable to sign. Sorry.") |
| 672 | } |
| 673 | stateInfo := h.state[requestID] |
| 674 | for extensionName := range stateInfo.request.Extensions { |
| 675 | // sshd up to version 6.8 has a bug where optional extensions are |
| 676 | // treated as critical. If a cert contains any non-standard |
| 677 | // extensions, like ours, the server rejects the cert because it |
| 678 | // doesn't understand the extension. To cope with this we simply |
| 679 | // strip our non-standard extensions before doing the final |
| 680 | // signature. https://bugzilla.mindrot.org/show_bug.cgi?id=2387 |
| 681 | if strings.Contains(extensionName, "@") { |
| 682 | delete(stateInfo.request.Extensions, extensionName) |
| 683 | } |
| 684 | } |
| 685 | stateInfo.request.SignCert(rand.Reader, signer) |
| 686 | stateInfo.certSigned = true |
| 687 | // this is weird. see: https://code.google.com/p/go/issues/detail?id=3117 |
| 688 | h.state[requestID] = stateInfo |
| 689 | return true, nil |
| 690 | } |
| 691 | return false, nil |
| 692 | } |
| 693 | |
| 694 | func signdFlags() []cli.Flag { |
| 695 | home := os.Getenv("HOME") |
no outgoing calls
no test coverage detected