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{
|
|
|
|
Root: []string{
|
|
|
|
"config/*",
|
|
|
|
"revoke/*",
|
2015-06-12 01:57:05 +00:00
|
|
|
"crl/rotate",
|
2015-05-15 16:13:05 +00:00
|
|
|
},
|
|
|
|
Unauthenticated: []string{
|
|
|
|
"cert/*",
|
|
|
|
"ca/pem",
|
|
|
|
"ca",
|
|
|
|
"crl/pem",
|
|
|
|
"crl",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Paths: []*framework.Path{
|
|
|
|
pathRoles(&b),
|
|
|
|
pathConfigCA(&b),
|
2015-06-19 16:48:18 +00:00
|
|
|
pathConfigCRL(&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.
|
|
|
|
`
|