diff options
Diffstat (limited to 'issuer.go')
| -rw-r--r-- | issuer.go | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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) |
