2016-12-26 14:03:27 +00:00
|
|
|
package ssh
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rand"
|
2017-03-16 15:14:17 +00:00
|
|
|
"crypto/sha256"
|
|
|
|
"encoding/hex"
|
2017-03-02 20:38:34 +00:00
|
|
|
"errors"
|
2016-12-26 14:03:27 +00:00
|
|
|
"fmt"
|
2017-03-01 20:50:23 +00:00
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
2016-12-26 14:03:27 +00:00
|
|
|
"github.com/hashicorp/vault/helper/certutil"
|
2017-03-07 16:21:22 +00:00
|
|
|
"github.com/hashicorp/vault/helper/parseutil"
|
2017-03-01 20:50:23 +00:00
|
|
|
"github.com/hashicorp/vault/helper/strutil"
|
2016-12-26 14:03:27 +00:00
|
|
|
"github.com/hashicorp/vault/logical"
|
|
|
|
"github.com/hashicorp/vault/logical/framework"
|
|
|
|
"golang.org/x/crypto/ssh"
|
|
|
|
)
|
|
|
|
|
|
|
|
type creationBundle struct {
|
|
|
|
KeyId string
|
|
|
|
ValidPrincipals []string
|
|
|
|
PublicKey ssh.PublicKey
|
|
|
|
CertificateType uint32
|
|
|
|
TTL time.Duration
|
2017-03-08 22:36:21 +00:00
|
|
|
Signer ssh.Signer
|
2016-12-26 14:03:27 +00:00
|
|
|
Role *sshRole
|
2017-03-08 22:36:21 +00:00
|
|
|
CriticalOptions map[string]string
|
|
|
|
Extensions map[string]string
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func pathSign(b *backend) *framework.Path {
|
|
|
|
return &framework.Path{
|
|
|
|
Pattern: "sign/" + framework.GenericNameRegex("role"),
|
|
|
|
|
|
|
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
|
|
|
logical.UpdateOperation: b.pathSign,
|
|
|
|
},
|
|
|
|
|
|
|
|
Fields: map[string]*framework.FieldSchema{
|
|
|
|
"role": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: `The desired role with configuration for this request.`,
|
|
|
|
},
|
|
|
|
"ttl": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: `The requested Time To Live for the SSH certificate;
|
|
|
|
sets the expiration date. If not specified
|
|
|
|
the role default, backend default, or system
|
|
|
|
default TTL is used, in that order. Cannot
|
|
|
|
be later than the role max TTL.`,
|
|
|
|
},
|
|
|
|
"public_key": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: `SSH public key that should be signed.`,
|
|
|
|
},
|
|
|
|
"valid_principals": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: `Valid principals, either usernames or hostnames, that the certificate should be signed for.`,
|
|
|
|
},
|
|
|
|
"cert_type": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: `Type of certificate to be created; either "user" or "host".`,
|
|
|
|
Default: "user",
|
|
|
|
},
|
|
|
|
"key_id": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: `Key id that the created certificate should have. If not specified, the display name of the token will be used.`,
|
|
|
|
},
|
|
|
|
"critical_options": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeMap,
|
|
|
|
Description: `Critical options that the certificate should be signed for.`,
|
|
|
|
},
|
|
|
|
"extensions": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeMap,
|
|
|
|
Description: `Extensions that the certificate should be signed for.`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
HelpSynopsis: `Request signing an SSH key using a certain role with the provided details.`,
|
|
|
|
HelpDescription: `This path allows SSH keys to be signed according to the policy of the given role.`,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *backend) pathSign(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
|
|
|
roleName := data.Get("role").(string)
|
|
|
|
|
|
|
|
// Get the role
|
|
|
|
role, err := b.getRole(req.Storage, roleName)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if role == nil {
|
|
|
|
return logical.ErrorResponse(fmt.Sprintf("Unknown role: %s", roleName)), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return b.pathSignCertificate(req, data, role)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *backend) pathSignCertificate(req *logical.Request, data *framework.FieldData, role *sshRole) (*logical.Response, error) {
|
|
|
|
publicKey := data.Get("public_key").(string)
|
|
|
|
if publicKey == "" {
|
2017-03-02 20:38:34 +00:00
|
|
|
return logical.ErrorResponse("missing public_key"), nil
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
2017-02-28 22:08:10 +00:00
|
|
|
userPublicKey, err := parsePublicSSHKey(publicKey)
|
2016-12-26 14:03:27 +00:00
|
|
|
if err != nil {
|
2017-03-08 22:36:21 +00:00
|
|
|
return logical.ErrorResponse(fmt.Sprintf("failed to parse public_key as SSH key: %s", err)), nil
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 20:38:34 +00:00
|
|
|
// Note that these various functions always return "user errors" so we pass
|
|
|
|
// them as 4xx values
|
2017-03-16 15:14:17 +00:00
|
|
|
keyId, err := b.calculateKeyId(data, req, role, userPublicKey)
|
2017-03-16 12:45:11 +00:00
|
|
|
if err != nil {
|
|
|
|
return logical.ErrorResponse(err.Error()), nil
|
|
|
|
}
|
|
|
|
|
2016-12-26 14:03:27 +00:00
|
|
|
certificateType, err := b.calculateCertificateType(data, role)
|
|
|
|
if err != nil {
|
2017-03-02 20:38:34 +00:00
|
|
|
return logical.ErrorResponse(err.Error()), nil
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
2017-02-28 08:24:31 +00:00
|
|
|
var parsedPrincipals []string
|
|
|
|
if certificateType == ssh.HostCert {
|
|
|
|
parsedPrincipals, err = b.calculateValidPrincipals(data, "", role.AllowedDomains, validateValidPrincipalForHosts(role))
|
|
|
|
if err != nil {
|
2017-03-02 20:38:34 +00:00
|
|
|
return logical.ErrorResponse(err.Error()), nil
|
2017-02-28 08:24:31 +00:00
|
|
|
}
|
|
|
|
} else {
|
2017-02-28 22:08:10 +00:00
|
|
|
parsedPrincipals, err = b.calculateValidPrincipals(data, role.DefaultUser, role.AllowedUsers, strutil.StrListContains)
|
2017-02-28 08:24:31 +00:00
|
|
|
if err != nil {
|
2017-03-02 20:38:34 +00:00
|
|
|
return logical.ErrorResponse(err.Error()), nil
|
2017-02-28 08:24:31 +00:00
|
|
|
}
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 20:38:34 +00:00
|
|
|
ttl, err := b.calculateTTL(data, role)
|
2016-12-26 14:03:27 +00:00
|
|
|
if err != nil {
|
2017-03-02 20:38:34 +00:00
|
|
|
return logical.ErrorResponse(err.Error()), nil
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
criticalOptions, err := b.calculateCriticalOptions(data, role)
|
|
|
|
if err != nil {
|
2017-03-02 20:38:34 +00:00
|
|
|
return logical.ErrorResponse(err.Error()), nil
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extensions, err := b.calculateExtensions(data, role)
|
|
|
|
if err != nil {
|
2017-03-02 20:38:34 +00:00
|
|
|
return logical.ErrorResponse(err.Error()), nil
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 22:36:21 +00:00
|
|
|
privateKeyEntry, err := caKey(req.Storage, caPrivateKey)
|
2016-12-26 14:03:27 +00:00
|
|
|
if err != nil {
|
2017-03-08 22:36:21 +00:00
|
|
|
return nil, fmt.Errorf("failed to read CA private key: %v", err)
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
2017-03-08 22:36:21 +00:00
|
|
|
if privateKeyEntry == nil || privateKeyEntry.Key == "" {
|
|
|
|
return nil, fmt.Errorf("failed to read CA private key")
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 22:36:21 +00:00
|
|
|
signer, err := ssh.ParsePrivateKey([]byte(privateKeyEntry.Key))
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to parse stored CA private key: %v", err)
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 22:36:21 +00:00
|
|
|
cBundle := creationBundle{
|
2017-02-28 08:24:31 +00:00
|
|
|
KeyId: keyId,
|
|
|
|
PublicKey: userPublicKey,
|
2017-03-08 22:36:21 +00:00
|
|
|
Signer: signer,
|
2017-02-28 08:24:31 +00:00
|
|
|
ValidPrincipals: parsedPrincipals,
|
|
|
|
TTL: ttl,
|
|
|
|
CertificateType: certificateType,
|
|
|
|
Role: role,
|
2017-03-08 22:36:21 +00:00
|
|
|
CriticalOptions: criticalOptions,
|
|
|
|
Extensions: extensions,
|
2017-02-28 08:24:31 +00:00
|
|
|
}
|
2016-12-26 14:03:27 +00:00
|
|
|
|
2017-03-08 22:36:21 +00:00
|
|
|
certificate, err := cBundle.sign()
|
2016-12-26 14:03:27 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2017-03-02 20:38:34 +00:00
|
|
|
signedSSHCertificate := ssh.MarshalAuthorizedKey(certificate)
|
|
|
|
if len(signedSSHCertificate) == 0 {
|
|
|
|
return nil, fmt.Errorf("error marshaling signed certificate")
|
|
|
|
}
|
2016-12-26 14:03:27 +00:00
|
|
|
|
2017-02-28 22:08:10 +00:00
|
|
|
response := &logical.Response{
|
|
|
|
Data: map[string]interface{}{
|
2016-12-26 14:03:27 +00:00
|
|
|
"serial_number": strconv.FormatUint(certificate.Serial, 16),
|
2017-03-02 20:38:34 +00:00
|
|
|
"signed_key": string(signedSSHCertificate),
|
2016-12-26 14:03:27 +00:00
|
|
|
},
|
2017-02-28 22:08:10 +00:00
|
|
|
}
|
2016-12-26 14:03:27 +00:00
|
|
|
|
|
|
|
return response, nil
|
|
|
|
}
|
|
|
|
|
2017-02-28 08:24:31 +00:00
|
|
|
func (b *backend) calculateValidPrincipals(data *framework.FieldData, defaultPrincipal, principalsAllowedByRole string, validatePrincipal func([]string, string) bool) ([]string, error) {
|
2017-03-08 22:36:21 +00:00
|
|
|
validPrincipals := ""
|
|
|
|
validPrincipalsRaw, ok := data.GetOk("valid_principals")
|
|
|
|
if ok {
|
|
|
|
validPrincipals = validPrincipalsRaw.(string)
|
|
|
|
} else {
|
|
|
|
validPrincipals = defaultPrincipal
|
|
|
|
}
|
|
|
|
|
|
|
|
parsedPrincipals := strutil.ParseDedupAndSortStrings(validPrincipals, ",")
|
|
|
|
allowedPrincipals := strutil.ParseDedupAndSortStrings(principalsAllowedByRole, ",")
|
|
|
|
switch {
|
|
|
|
case len(parsedPrincipals) == 0:
|
|
|
|
// There is nothing to process
|
|
|
|
return nil, nil
|
|
|
|
case len(allowedPrincipals) == 0:
|
|
|
|
// User has requested principals to be set, but role is not configured
|
|
|
|
// with any principals
|
|
|
|
return nil, fmt.Errorf("role is not configured to allow any principles")
|
|
|
|
default:
|
|
|
|
// Role was explicitly configured to allow any principal.
|
|
|
|
if principalsAllowedByRole == "*" {
|
|
|
|
return parsedPrincipals, nil
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 22:36:21 +00:00
|
|
|
for _, principal := range parsedPrincipals {
|
|
|
|
if !validatePrincipal(allowedPrincipals, principal) {
|
|
|
|
return nil, fmt.Errorf("%v is not a valid value for valid_principals", principal)
|
|
|
|
}
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
2017-03-08 22:36:21 +00:00
|
|
|
return parsedPrincipals, nil
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-28 08:24:31 +00:00
|
|
|
func validateValidPrincipalForHosts(role *sshRole) func([]string, string) bool {
|
|
|
|
return func(allowedPrincipals []string, validPrincipal string) bool {
|
2016-12-26 14:03:27 +00:00
|
|
|
for _, allowedPrincipal := range allowedPrincipals {
|
|
|
|
if allowedPrincipal == validPrincipal && role.AllowBareDomains {
|
|
|
|
return true
|
|
|
|
}
|
2017-03-01 20:50:23 +00:00
|
|
|
if role.AllowSubdomains && strings.HasSuffix(validPrincipal, "."+allowedPrincipal) {
|
2016-12-26 14:03:27 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *backend) calculateCertificateType(data *framework.FieldData, role *sshRole) (uint32, error) {
|
|
|
|
requestedCertificateType := data.Get("cert_type").(string)
|
|
|
|
|
|
|
|
var certificateType uint32
|
|
|
|
switch requestedCertificateType {
|
|
|
|
case "user":
|
|
|
|
if !role.AllowUserCertificates {
|
2017-03-08 22:36:21 +00:00
|
|
|
return 0, errors.New("cert_type 'user' is not allowed by role")
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
certificateType = ssh.UserCert
|
|
|
|
case "host":
|
|
|
|
if !role.AllowHostCertificates {
|
2017-03-08 22:36:21 +00:00
|
|
|
return 0, errors.New("cert_type 'host' is not allowed by role")
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
certificateType = ssh.HostCert
|
|
|
|
default:
|
2017-03-08 22:36:21 +00:00
|
|
|
return 0, errors.New("cert_type must be either 'user' or 'host'")
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return certificateType, nil
|
|
|
|
}
|
|
|
|
|
2017-03-16 15:14:17 +00:00
|
|
|
func (b *backend) calculateKeyId(data *framework.FieldData, req *logical.Request, role *sshRole, pubKey ssh.PublicKey) (string, error) {
|
|
|
|
reqId := data.Get("key_id").(string)
|
2017-03-16 12:45:11 +00:00
|
|
|
|
2017-03-16 15:14:17 +00:00
|
|
|
if reqId != "" {
|
|
|
|
if !role.AllowUserKeyIDs {
|
|
|
|
return "", fmt.Errorf("setting key_id is not allowed by role")
|
|
|
|
}
|
|
|
|
return reqId, nil
|
2017-03-16 12:45:11 +00:00
|
|
|
}
|
|
|
|
|
2017-03-16 15:14:17 +00:00
|
|
|
keyHash := sha256.Sum256(pubKey.Marshal())
|
|
|
|
keyId := hex.EncodeToString(keyHash[:])
|
|
|
|
|
|
|
|
if req.DisplayName != "" {
|
|
|
|
keyId = fmt.Sprintf("%s-%s", req.DisplayName, keyId)
|
2017-03-16 12:45:11 +00:00
|
|
|
}
|
|
|
|
|
2017-03-16 15:14:17 +00:00
|
|
|
keyId = fmt.Sprintf("vault-%s", keyId)
|
|
|
|
|
2017-03-16 12:45:11 +00:00
|
|
|
return keyId, nil
|
|
|
|
}
|
|
|
|
|
2016-12-26 14:03:27 +00:00
|
|
|
func (b *backend) calculateCriticalOptions(data *framework.FieldData, role *sshRole) (map[string]string, error) {
|
|
|
|
unparsedCriticalOptions := data.Get("critical_options").(map[string]interface{})
|
|
|
|
if len(unparsedCriticalOptions) == 0 {
|
|
|
|
return role.DefaultCriticalOptions, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
criticalOptions := convertMapToStringValue(unparsedCriticalOptions)
|
|
|
|
|
|
|
|
if role.AllowedCriticalOptions != "" {
|
|
|
|
notAllowedOptions := []string{}
|
|
|
|
allowedCriticalOptions := strings.Split(role.AllowedCriticalOptions, ",")
|
|
|
|
|
|
|
|
for option := range criticalOptions {
|
2017-02-28 22:08:10 +00:00
|
|
|
if !strutil.StrListContains(allowedCriticalOptions, option) {
|
2016-12-26 14:03:27 +00:00
|
|
|
notAllowedOptions = append(notAllowedOptions, option)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(notAllowedOptions) != 0 {
|
2017-03-02 20:38:34 +00:00
|
|
|
return nil, fmt.Errorf("Critical options not on allowed list: %v", notAllowedOptions)
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return criticalOptions, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *backend) calculateExtensions(data *framework.FieldData, role *sshRole) (map[string]string, error) {
|
|
|
|
unparsedExtensions := data.Get("extensions").(map[string]interface{})
|
|
|
|
if len(unparsedExtensions) == 0 {
|
|
|
|
return role.DefaultExtensions, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
extensions := convertMapToStringValue(unparsedExtensions)
|
|
|
|
|
|
|
|
if role.AllowedExtensions != "" {
|
|
|
|
notAllowed := []string{}
|
|
|
|
allowedExtensions := strings.Split(role.AllowedExtensions, ",")
|
|
|
|
|
|
|
|
for extension := range extensions {
|
2017-02-28 22:08:10 +00:00
|
|
|
if !strutil.StrListContains(allowedExtensions, extension) {
|
2016-12-26 14:03:27 +00:00
|
|
|
notAllowed = append(notAllowed, extension)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(notAllowed) != 0 {
|
2017-03-08 22:36:21 +00:00
|
|
|
return nil, fmt.Errorf("extensions %v are not on allowed list", notAllowed)
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return extensions, nil
|
|
|
|
}
|
|
|
|
|
2017-03-02 20:38:34 +00:00
|
|
|
func (b *backend) calculateTTL(data *framework.FieldData, role *sshRole) (time.Duration, error) {
|
2016-12-26 14:03:27 +00:00
|
|
|
|
|
|
|
var ttl, maxTTL time.Duration
|
|
|
|
var ttlField string
|
|
|
|
ttlFieldInt, ok := data.GetOk("ttl")
|
|
|
|
if !ok {
|
|
|
|
ttlField = role.TTL
|
|
|
|
} else {
|
|
|
|
ttlField = ttlFieldInt.(string)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(ttlField) == 0 {
|
|
|
|
ttl = b.System().DefaultLeaseTTL()
|
|
|
|
} else {
|
|
|
|
var err error
|
2017-03-07 16:21:22 +00:00
|
|
|
ttl, err = parseutil.ParseDurationSecond(ttlField)
|
2016-12-26 14:03:27 +00:00
|
|
|
if err != nil {
|
2017-03-02 20:38:34 +00:00
|
|
|
return 0, fmt.Errorf("invalid requested ttl: %s", err)
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(role.MaxTTL) == 0 {
|
|
|
|
maxTTL = b.System().MaxLeaseTTL()
|
|
|
|
} else {
|
|
|
|
var err error
|
2017-03-07 16:21:22 +00:00
|
|
|
maxTTL, err = parseutil.ParseDurationSecond(role.MaxTTL)
|
2016-12-26 14:03:27 +00:00
|
|
|
if err != nil {
|
2017-03-02 20:38:34 +00:00
|
|
|
return 0, fmt.Errorf("invalid requested max ttl: %s", err)
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ttl > maxTTL {
|
|
|
|
// Don't error if they were using system defaults, only error if
|
|
|
|
// they specifically chose a bad TTL
|
|
|
|
if len(ttlField) == 0 {
|
|
|
|
ttl = maxTTL
|
|
|
|
} else {
|
2017-03-02 20:38:34 +00:00
|
|
|
return 0, fmt.Errorf("ttl is larger than maximum allowed (%d)", maxTTL/time.Second)
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ttl, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *creationBundle) sign() (*ssh.Certificate, error) {
|
|
|
|
serialNumber, err := certutil.GenerateSerialNumber()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
now := time.Now()
|
|
|
|
|
|
|
|
certificate := &ssh.Certificate{
|
|
|
|
Serial: serialNumber.Uint64(),
|
|
|
|
Key: b.PublicKey,
|
|
|
|
KeyId: b.KeyId,
|
|
|
|
ValidPrincipals: b.ValidPrincipals,
|
|
|
|
ValidAfter: uint64(now.Add(-30 * time.Second).In(time.UTC).Unix()),
|
|
|
|
ValidBefore: uint64(now.Add(b.TTL).In(time.UTC).Unix()),
|
|
|
|
CertType: b.CertificateType,
|
|
|
|
Permissions: ssh.Permissions{
|
2017-03-08 22:36:21 +00:00
|
|
|
CriticalOptions: b.CriticalOptions,
|
|
|
|
Extensions: b.Extensions,
|
2016-12-26 14:03:27 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-03-08 22:36:21 +00:00
|
|
|
err = certificate.SignCert(rand.Reader, b.Signer)
|
2016-12-26 14:03:27 +00:00
|
|
|
if err != nil {
|
2017-03-08 22:36:21 +00:00
|
|
|
return nil, fmt.Errorf("failed to generate signed SSH key")
|
2016-12-26 14:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return certificate, nil
|
|
|
|
}
|