-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
implement a no_store option for pki roles, refs #2511 #2565
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,10 +240,12 @@ func (b *backend) pathIssueSignCert( | |
resp.Secret.TTL = parsedBundle.Certificate.NotAfter.Sub(time.Now()) | ||
} | ||
|
||
err = req.Storage.Put(&logical.StorageEntry{ | ||
Key: "certs/" + cb.SerialNumber, | ||
Value: parsedBundle.CertificateBytes, | ||
}) | ||
if !*role.NoStore { | ||
err = req.Storage.Put(&logical.StorageEntry{ | ||
Key: "certs/" + cb.SerialNumber, | ||
Value: parsedBundle.CertificateBytes, | ||
}) | ||
} | ||
if err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you move this error handling into the previous block? |
||
return nil, fmt.Errorf("Unable to store certificate locally: %v", err) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,6 +204,17 @@ to the CRL. When large number of certificates are generated with long | |
lifetimes, it is recommended that lease generation be disabled, as large amount of | ||
leases adversely affect the startup time of Vault.`, | ||
}, | ||
"no_store": &framework.FieldSchema{ | ||
Type: framework.TypeBool, | ||
Default: false, | ||
Description: ` | ||
If set, certificates issued/signed against this role will not be stored in the | ||
in the storage backend. This can improve performance when issuing large numbers | ||
of certificates. However, certificates issued in this way cannot be enumerated | ||
or revoked, so this option is recommended only for certificates that are | ||
non-sensitive, or extremely short-lived. This option implies a value of "false" | ||
for "generate_lease".`, | ||
}, | ||
}, | ||
|
||
Callbacks: map[logical.Operation]framework.OperationFunc{ | ||
|
@@ -280,6 +291,13 @@ func (b *backend) getRole(s logical.Storage, n string) (*roleEntry, error) { | |
modified = true | ||
} | ||
|
||
// analogous upgrade for no_store | ||
if result.NoStore == nil { | ||
result.NoStore = new(bool) | ||
*result.NoStore = false | ||
modified = true | ||
} | ||
|
||
if modified { | ||
jsonEntry, err := logical.StorageEntryJSON("role/"+n, &result) | ||
if err != nil { | ||
|
@@ -384,9 +402,16 @@ func (b *backend) pathRoleCreate( | |
OU: data.Get("ou").(string), | ||
Organization: data.Get("organization").(string), | ||
GenerateLease: new(bool), | ||
NoStore: new(bool), | ||
} | ||
|
||
*entry.GenerateLease = data.Get("generate_lease").(bool) | ||
*entry.NoStore = data.Get("no_store").(bool) | ||
// no_store implies generate_lease := false | ||
if *entry.NoStore { | ||
*entry.GenerateLease = false | ||
} else { | ||
*entry.GenerateLease = data.Get("generate_lease").(bool) | ||
} | ||
|
||
if entry.KeyType == "rsa" && entry.KeyBits < 2048 { | ||
return logical.ErrorResponse("RSA keys < 2048 bits are unsafe and not supported"), nil | ||
|
@@ -504,6 +529,7 @@ type roleEntry struct { | |
OU string `json:"ou" structs:"ou" mapstructure:"ou"` | ||
Organization string `json:"organization" structs:"organization" mapstructure:"organization"` | ||
GenerateLease *bool `json:"generate_lease,omitempty" structs:"generate_lease,omitempty"` | ||
NoStore *bool `json:"no_store,omitempty" structs:"no_store,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't need to be a |
||
} | ||
|
||
const pathListRolesHelpSyn = `List the existing roles in this backend` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to dereference the role here.