cloudflare / cfssl

CFSSL: Cloudflare's PKI and TLS toolkit
https://cfssl.org/
BSD 2-Clause "Simplified" License
8.76k stars 1.11k forks source link

cannot unmarshal string into Go value #467

Closed yurivict closed 8 years ago

yurivict commented 8 years ago

Running with this csr.json

{
    "bundle": "CERT_BUNDLE_IN_PEM",
    "crt": "LEAF_CERT_IN_PEM",
    "crl_support": true,
    "expires": "2015-12-31T23:59:59Z",
    "hostnames": ["example.com"],
    "issuer": "ISSUER CERT SUBJECT",
    "key": "KEY_IN_PEM",
    "key_size": 2048,
    "key_type": "2048-bit RSA",
    "ocsp": ["http://ocsp.example-ca.com"],
    "ocsp_support": true,
    "root": "ROOT_CA_CERT_IN_PEM",
    "signature": "SHA1WithRSA",
    "subject": "LEAF CERT SUBJECT",
    "status": {
        "rebundled": false,
        "expiring_SKIs": [],
        "untrusted_root_stores": [],
        "messages": [],
        "code": 0
    }
}

causes this error:

$ cfssl genkey csr.json
json: cannot unmarshal string into Go value of type csr.KeyRequest

Error message doesn' t help to understand what is wrong. It talks about the Go language problem.

Is this a parsing error? Which string is wrong?

IMO error messages should help understand what is the problem. Language shouldn't be mentioned, since it is irrelevant.

lziest commented 8 years ago

you are putting a bundle output as a csr.json. An example of csr.json is at https://github.com/cloudflare/cfssl/blob/master/cli/genkey/testdata/csr.json

0xhaven commented 8 years ago

Another good way is to

$ cfssl print-defaults csr
{
    "CN": "example.net",
    "hosts": [
        "example.net",
        "www.example.net"
    ],
    "key": {
        "algo": "ecdsa",
        "size": 256
    },
    "names": [
        {
            "C": "US",
            "L": "CA",
            "ST": "San Francisco"
        }
    ]
}