Skip to content

Commit

Permalink
Allow entering PKI URLs as arrays. (#3409)
Browse files Browse the repository at this point in the history
Fixes #3407
  • Loading branch information
jefferai committed Oct 3, 2017
1 parent f76633c commit 04e8d16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
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

0 comments on commit 04e8d16

Please sign in to comment.