2015-05-15 16:13:05 +00:00
|
|
|
package pki
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
2015-06-19 16:48:18 +00:00
|
|
|
"sync"
|
|
|
|
"time"
|
2015-05-15 16:13:05 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/vault/logical"
|
|
|
|
"github.com/hashicorp/vault/logical/framework"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Factory creates a new backend implementing the logical.Backend interface
|
2015-07-01 00:45:20 +00:00
|
|
|
func Factory(conf *logical.BackendConfig) (logical.Backend, error) {
|
|
|
|
return Backend().Setup(conf)
|
2015-05-15 16:13:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Backend returns a new Backend framework struct
|
|
|
|
func Backend() *framework.Backend {
|
|
|
|
var b backend
|
|
|
|
b.Backend = &framework.Backend{
|
|
|
|
Help: strings.TrimSpace(backendHelp),
|
|
|
|
|
|
|
|
PathsSpecial: &logical.Paths{
|
|
|
|
Unauthenticated: []string{
|
|
|
|
"cert/*",
|
|
|
|
"ca/pem",
|
|
|
|
"ca",
|
|
|
|
"crl/pem",
|
|
|
|
"crl",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Paths: []*framework.Path{
|
|
|
|
pathRoles(&b),
|
2015-11-18 15:16:09 +00:00
|
|
|
pathGenerateRoot(&b),
|
|
|
|
pathGenerateIntermediate(&b),
|
|
|
|
pathSetSignedIntermediate(&b),
|
|
|
|
pathSignIntermediate(&b),
|
2015-05-15 16:13:05 +00:00
|
|
|
pathConfigCA(&b),
|
2015-06-19 16:48:18 +00:00
|
|
|
pathConfigCRL(&b),
|
2015-10-14 01:13:40 +00:00
|
|
|
pathConfigURLs(&b),
|
2015-11-18 15:16:09 +00:00
|
|
|
pathSignVerbatim(&b),
|
2015-09-30 01:48:31 +00:00
|
|
|
pathSign(&b),
|
2015-05-15 16:13:05 +00:00
|
|
|
pathIssue(&b),
|
|
|
|
pathRotateCRL(&b),
|
|
|
|
pathFetchCA(&b),
|
|
|
|
pathFetchCRL(&b),
|
|
|
|
pathFetchCRLViaCertPath(&b),
|
|
|
|
pathFetchValid(&b),
|
|
|
|
pathRevoke(&b),
|
|
|
|
},
|
|
|
|
|
|
|
|
Secrets: []*framework.Secret{
|
|
|
|
secretCerts(&b),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2015-06-19 16:48:18 +00:00
|
|
|
b.crlLifetime = time.Hour * 72
|
|
|
|
b.revokeStorageLock = &sync.Mutex{}
|
|
|
|
|
2015-05-15 16:13:05 +00:00
|
|
|
return b.Backend
|
|
|
|
}
|
|
|
|
|
|
|
|
type backend struct {
|
|
|
|
*framework.Backend
|
2015-06-19 16:48:18 +00:00
|
|
|
|
|
|
|
crlLifetime time.Duration
|
|
|
|
revokeStorageLock *sync.Mutex
|
2015-05-15 16:13:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const backendHelp = `
|
|
|
|
The PKI backend dynamically generates X509 server and client certificates.
|
|
|
|
|
2015-06-12 03:16:13 +00:00
|
|
|
After mounting this backend, configure the CA using the "pem_bundle" endpoint within
|
2015-05-15 16:13:05 +00:00
|
|
|
the "config/" path.
|
|
|
|
`
|