aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--issuer.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/issuer.go b/issuer.go
index 3025be6..ed18919 100644
--- a/issuer.go
+++ b/issuer.go
@@ -32,14 +32,21 @@ type Issuer struct {
// NewIssuer create and initialize new issuer from raw value.
// If the rsaPrivateKey is not nil, that means the rawConfig is encrypted.
func NewIssuer(label, rawConfig string, rsaPrivateKey *rsa.PrivateKey) (issuer *Issuer, err error) {
- var (
- logp = `NewIssuer`
+ var logp = `NewIssuer`
- vals []string
- vbytes []byte
- )
+ label = strings.TrimSpace(label)
+ if len(label) == 0 {
+ return nil, fmt.Errorf(`%s: empty label`, logp)
+ }
+
+ rawConfig = strings.TrimSpace(rawConfig)
+ if len(rawConfig) == 0 {
+ return nil, fmt.Errorf(`%s: empty configuration`, logp)
+ }
if rsaPrivateKey != nil {
+ var vbytes []byte
+
vbytes, err = base64.StdEncoding.DecodeString(rawConfig)
if err != nil {
return nil, fmt.Errorf(`%s: %w`, logp, err)
@@ -53,6 +60,8 @@ func NewIssuer(label, rawConfig string, rsaPrivateKey *rsa.PrivateKey) (issuer *
rawConfig = string(vbytes)
}
+ var vals []string
+
vals = strings.Split(rawConfig, valueSeparator)
if len(vals) < 2 {
return nil, fmt.Errorf(`%s: invalid value %q`, logp, rawConfig)