Skip to content
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

Allow entering PKI URLs as arrays. #3409

Merged
merged 1 commit into from
Oct 3, 2017
Merged
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
16 changes: 6 additions & 10 deletions builtin/logical/pki/path_config_urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pki

import (
"fmt"
"strings"

"github.com/asaskevich/govalidator"
"github.com/fatih/structs"
Expand All @@ -15,19 +14,19 @@ func pathConfigURLs(b *backend) *framework.Path {
Pattern: "config/urls",
Fields: map[string]*framework.FieldSchema{
"issuing_certificates": &framework.FieldSchema{
Type: framework.TypeString,
Type: framework.TypeCommaStringSlice,
Description: `Comma-separated list of URLs to be used
for the issuing certificate attribute`,
},

"crl_distribution_points": &framework.FieldSchema{
Type: framework.TypeString,
Type: framework.TypeCommaStringSlice,
Description: `Comma-separated list of URLs to be used
for the CRL distribution points attribute`,
},

"ocsp_servers": &framework.FieldSchema{
Type: framework.TypeString,
Type: framework.TypeCommaStringSlice,
Description: `Comma-separated list of URLs to be used
for the OCSP servers attribute`,
},
Expand Down Expand Up @@ -119,24 +118,21 @@ func (b *backend) pathWriteURL(
}

if urlsInt, ok := data.GetOk("issuing_certificates"); ok {
splitURLs := strings.Split(urlsInt.(string), ",")
entries.IssuingCertificates = splitURLs
entries.IssuingCertificates = urlsInt.([]string)
if badURL := validateURLs(entries.IssuingCertificates); badURL != "" {
return logical.ErrorResponse(fmt.Sprintf(
"invalid URL found in issuing certificates: %s", badURL)), nil
}
}
if urlsInt, ok := data.GetOk("crl_distribution_points"); ok {
splitURLs := strings.Split(urlsInt.(string), ",")
entries.CRLDistributionPoints = splitURLs
entries.CRLDistributionPoints = urlsInt.([]string)
if badURL := validateURLs(entries.CRLDistributionPoints); badURL != "" {
return logical.ErrorResponse(fmt.Sprintf(
"invalid URL found in CRL distribution points: %s", badURL)), nil
}
}
if urlsInt, ok := data.GetOk("ocsp_servers"); ok {
splitURLs := strings.Split(urlsInt.(string), ",")
entries.OCSPServers = splitURLs
entries.OCSPServers = urlsInt.([]string)
if badURL := validateURLs(entries.OCSPServers); badURL != "" {
return logical.ErrorResponse(fmt.Sprintf(
"invalid URL found in OCSP servers: %s", badURL)), nil
Expand Down
8 changes: 5 additions & 3 deletions website/source/api/secret/pki/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,15 @@ parameter.
### Parameters

- `issuing_certificates` `(array<string>: nil)` – Specifies the URL values for
the Issuing Certificate field.
the Issuing Certificate field. This can be an array or a comma-separated
string list.

- `crl_distribution_points` `(array<string>: nil)` – Specifies the URL values
for the CRL Distribution Points field.
for the CRL Distribution Points field. This can be an array or a
comma-separated string list.

- `ocsp_servers` `(array<string>: nil)` – Specifies the URL values for the OCSP
Servers field.
Servers field. This can be an array or a comma-separated string list.

### Sample Payload

Expand Down