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
|
2016-06-10 19:53:02 +00:00
|
|
|
func Backend() *backend {
|
2015-05-15 16:13:05 +00:00
|
|
|
var b backend
|
|
|
|
b.Backend = &framework.Backend{
|
|
|
|
Help: strings.TrimSpace(backendHelp),
|
|
|
|
|
|
|
|
PathsSpecial: &logical.Paths{
|
|
|
|
Unauthenticated: []string{
|
|
|
|
"cert/*",
|
|
|
|
"ca/pem",
|
2016-09-28 00:50:17 +00:00
|
|
|
"ca_chain",
|
2015-05-15 16:13:05 +00:00
|
|
|
"ca",
|
|
|
|
"crl/pem",
|
|
|
|
"crl",
|
|
|
|
},
|
2017-02-16 21:29:30 +00:00
|
|
|
|
|
|
|
LocalStorage: []string{
|
|
|
|
"revoked/",
|
|
|
|
"crl",
|
|
|
|
"certs/",
|
|
|
|
},
|
2015-05-15 16:13:05 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
Paths: []*framework.Path{
|
2016-01-28 20:18:07 +00:00
|
|
|
pathListRoles(&b),
|
2015-05-15 16:13:05 +00:00
|
|
|
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),
|
2016-09-28 00:50:17 +00:00
|
|
|
pathFetchCAChain(&b),
|
2015-05-15 16:13:05 +00:00
|
|
|
pathFetchCRL(&b),
|
|
|
|
pathFetchCRLViaCertPath(&b),
|
|
|
|
pathFetchValid(&b),
|
2016-06-08 15:46:58 +00:00
|
|
|
pathFetchListCerts(&b),
|
2015-05-15 16:13:05 +00:00
|
|
|
pathRevoke(&b),
|
2016-02-24 21:19:01 +00:00
|
|
|
pathTidy(&b),
|
2015-05-15 16:13:05 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
Secrets: []*framework.Secret{
|
|
|
|
secretCerts(&b),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2015-06-19 16:48:18 +00:00
|
|
|
b.crlLifetime = time.Hour * 72
|
|
|
|
|
2016-06-10 19:53:02 +00:00
|
|
|
return &b
|
2015-05-15 16:13:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type backend struct {
|
|
|
|
*framework.Backend
|
2015-06-19 16:48:18 +00:00
|
|
|
|
|
|
|
crlLifetime time.Duration
|
2016-02-24 21:19:01 +00:00
|
|
|
revokeStorageLock sync.RWMutex
|
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.
|
|
|
|
`
|