Skip to content

updated CSR enrollment to use Keyfactor Client SDK #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: release-1.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Keyfactor Vault Secrets Engine Guide.docx
Makefile
sample_config.json
README.md
README.md
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- 1.4.2
- Updated the Hashicorp SDK libraries
- Incorporated the Keyfactor GO SDK for authentication and interaction with the Command API

- 1.4.1
- Updated CA and CA chain retreival to work for CA's hosted outside of Command (EJBCA)
- Updated Keyfactor Client library to 1.2.0
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,12 @@ instance of the plugin is named "keyfactor".
### Read CA cert

`vault read keyfactor/ca ca=<ca name>`
> Note: The certificate for the CA needs to have been imported into Command for this endpoint to return the CA Certificate

### Read CA chain

`vault read keyfactor/ca_chain ca=<ca name>`
> Note: _All_ certificates in the chain need to have been imported into Command for this endpoint to return the CA Certificate Chain



12 changes: 7 additions & 5 deletions backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import (
"strings"
"sync"

"github.com/Keyfactor/keyfactor-go-client-sdk/v24"
"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/logical"
)

const (
operationPrefixKeyfactor string = "keyfactor"
PluginVersion = "1.4.2" // this should match the release version of the plugin
)

// Factory configures and returns backend
Expand All @@ -39,7 +41,7 @@ type keyfactorBackend struct {
*framework.Backend
configLock sync.RWMutex
cachedConfig *keyfactorConfig
client *keyfactorClient
client *keyfactor.APIClient
}

// keyfactorBackend defines the target API keyfactorBackend
Expand Down Expand Up @@ -67,6 +69,7 @@ func backend() *keyfactorBackend {
BackendType: logical.TypeLogical,
Invalidate: b.invalidate,
InitializeFunc: b.Initialize,
RunningVersion: "v" + PluginVersion,
}
return &b
}
Expand Down Expand Up @@ -100,13 +103,12 @@ func (b *keyfactorBackend) invalidate(ctx context.Context, key string) {

// getClient locks the backend as it configures and creates a
// a new client for the target API
func (b *keyfactorBackend) getClient(ctx context.Context, s logical.Storage) (*keyfactorClient, error) {
func (b *keyfactorBackend) getClient(ctx context.Context, s logical.Storage) (*keyfactor.APIClient, error) {
b.configLock.RLock()
defer b.configLock.RUnlock()

if b.client != nil {
b.Logger().Debug("closing idle connections before returning existing client")
b.client.httpClient.CloseIdleConnections()
b.Logger().Trace("returning existing client")
return b.client, nil
}

Expand All @@ -127,5 +129,5 @@ func (b *keyfactorBackend) getClient(ctx context.Context, s logical.Storage) (*k
}

const keyfactorHelp = `
The Keyfactor backend is a pki service that issues and manages certificates.
The Keyfactor backend is a pki service that issues and manages certificates via the Keyfactor Command platform.
`
Loading
Loading