cfssl icon indicating copy to clipboard operation
cfssl copied to clipboard

'This certificate lacks a "hosts" field'

Open NKnusperer opened this issue 9 years ago • 13 comments

Why do I get this warning when trying to create a server certificate using an intermediate CA?

> cfssl version
Version: 1.2.0
Revision: dev
Runtime: go1.7.4

> cfssl gencert -ca .\intermediate.pem -ca-key .\intermediate-key.pem -config .\intermediate-signing-config.json -profile server .\server.json | cfssljson -bare server
2017/01/24 15:24:42 [INFO] generate received request
2017/01/24 15:24:42 [INFO] received CSR
2017/01/24 15:24:42 [INFO] generating key: ecdsa-256
2017/01/24 15:24:42 [INFO] encoded CSR
2017/01/24 15:24:42 [INFO] signed certificate with serial number 696568760590259425976467472465542311375839466856
2017/01/24 15:24:42 [WARNING] This certificate lacks a "hosts" field. This makes it unsuitable for
websites. For more information see the Baseline Requirements for the Issuance and Management
of Publicly-Trusted Certificates, v.1.1.6, from the CA/Browser Forum (https://cabforum.org);
specifically, section 10.2.3 ("Information Requirements").

intermediate-signing-config.json:

{
  "signing": {
    "default": {
      "expiry": "8760h"
    },
    "profiles": {
      "server": {
        "expiry": "8760h",
        "usages": [
          "signing",
          "key encipherment",
          "server auth"
        ]
      }
    }
  }
}

server.json

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

Output of cfssl-certinfo -cert .\server.pem:

{
  "subject": {
    "common_name": "example.net",
    "country": "US",
    "locality": "CA",
    "province": "San Francisco",
    "names": [
      "US",
      "San Francisco",
      "CA",
      "example.net"
    ]
  },
  "issuer": {
    "common_name": "My Intermediate CA"
    [Shortened]
  },
  "serial_number": "696568760590259425976467472465542311375839466856",
  "sans": [
    "example.net",
    "www.example.net"
  ],
  "not_before": "2017-01-24T14:20:00Z",
  "not_after": "2018-01-24T14:20:00Z",
  "sigalg": "ECDSAWithSHA256"
  [Shortened]
}

NKnusperer avatar Jan 24 '17 14:01 NKnusperer

I had the same issue. Passing in '-hostname="some.host.org"' to the cfssl gencert command made that warning go away.

cheddarwhizzy avatar Mar 10 '17 16:03 cheddarwhizzy

same issue here.

opsnull avatar Apr 05 '17 04:04 opsnull

same here , version 1.2.0

2017/04/05 14:35:49 [INFO] signed certificate with serial number 183005252934666287270114406130166503397851155556
2017/04/05 14:35:49 [WARNING] This certificate lacks a "hosts" field. This makes it unsuitable for
websites. For more information see the Baseline Requirements for the Issuance and Management
of Publicly-Trusted Certificates, v.1.1.6, from the CA/Browser Forum (https://cabforum.org);
specifically, section 10.2.3 ("Information Requirements").

cfssl version
Version: 1.2.0
Revision: dev
Runtime: go1.6

    "hosts": [
        "192.168.122.68",
        "ext.example.com",
        "coreos1.local",
        "coreos1"
    ],

judexzhu avatar Apr 05 '17 21:04 judexzhu

This is a bug in 1.2.0 which is already being fixed in the master branch. Compare the old https://github.com/cloudflare/cfssl/blob/db0d0650b6496bfe8061ec56a92edd32d8e75c30/cli/gencert/gencert.go#L142 and the new https://github.com/cloudflare/cfssl/blob/master/cli/gencert/gencert.go#L155

It should be fixed in the next release, otherwise, you can always try the tip of master. Thanks.

lziest avatar Apr 07 '17 22:04 lziest

Although this bug is fixed, but the release files have not been updated yet to reflect the fix.

yaxinlx avatar Dec 20 '17 06:12 yaxinlx

BTW, the latest official release was created Mar 29, 2016. When using the release and specifying '-hostname=xxx" arguments, the created key and cert are bad. So for who read this thread, the warning is harmless. Don't use the hostname argument if you use the 2016 release.

yaxinlx avatar Dec 20 '17 09:12 yaxinlx

I just re-downloaded the release file, it always output "Segmentation fault" in the end without keys being created. Someone just updated the release files in the past hour?

BTW, the release file built from the master branch works.

yaxinlx avatar Dec 20 '17 10:12 yaxinlx

Why it's closed? Binaries from https://pkg.cfssl.org/ still contains this issue

avoidik avatar Jan 15 '18 09:01 avoidik

i second avoidik above ^ this still exists in 1.2.0 binaries

zenion avatar Jan 19 '18 04:01 zenion

2019 September and this error still occurs

wilroboly avatar Sep 09 '19 14:09 wilroboly

Latest version on https://pkg.cfssl.org/ is still 1.2. And it is referenced by Kubernetes docs: https://kubernetes.io/docs/concepts/cluster-administration/certificates/#cfssl

Would be cool if either:

  • new release was published to https://pkg.cfssl.org
  • Kubernetes docs would reference latest release from: https://github.com/cloudflare/cfssl/releases/latest

IvanBoyko avatar Dec 19 '19 09:12 IvanBoyko

As a temporary solution I'm using temporary Docker container to build cfssl binaries on my own

FROM golang:stretch

ENV USER root

RUN DEBIAN_FRONTEND=noninteractive && \
    apt-get update && \
    apt-get install -y gcc-multilib gcc-mingw-w64 git-core

ARG TARGET_OS="windows"
ARG TARGET_ARCH="amd64"
ARG CGO_ENABLED=1
ARG TARGET_CC="x86_64-w64-mingw32-gcc-win32"
ARG CFSSL_VER="v1.4.0"

# CC=i686-w64-mingw32-gcc-win32
# GOARCH=386

ENV GOOS=${TARGET_OS}
ENV GOARCH=${TARGET_ARCH}
ENV CGO_ENABLED=${CGO_ENABLED}
ENV CC=${TARGET_CC}

RUN go get -d github.com/cloudflare/cfssl/cmd/cfssl && \
    go get -d github.com/cloudflare/cfssl/cmd/cfssljson && \
    cd /go/src/github.com/cloudflare/cfssl && \
    git fetch origin refs/tags/${CFSSL_VER} && \
    git checkout refs/tags/${CFSSL_VER} && \
    go build -o /usr/local/bin/cfssl github.com/cloudflare/cfssl/cmd/cfssl && \
    go build -o /usr/local/bin/cfssljson github.com/cloudflare/cfssl/cmd/cfssljson && \
    rm -rf /go/pkg && \
    rm -rf /go/src

RUN apt-get autoremove && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* && \
    rm -rf /tmp/* /var/tmp/*
#!/bin/bash

mkdir cfssl
docker build -t cfssl .
docker run -i --rm -v $(pwd)/cfssl:/cfssl cfssl bash -c "cp /usr/local/bin/cfssl /cfssl/cfssl ; cp /usr/local/bin/cfssljson /cfssl/cfssljson"

avoidik avatar Dec 19 '19 09:12 avoidik

There is even official Docker image, but it's latest version is 1.3.2 (10 May 2018), not the latest 1.4.1 Still it's > 1.2 so it has no bug described here.

$ docker run -it --rm cfssl/cfssl version
Version: 1.3.2
Revision: dev
Runtime: go1.9.2

The thing with Kubernetes and CKA exam is that you can't use external web-sites, only official one, which references version 1.2 of cfssl :( I'd love to use cfssl, but will likely switch to openssl or easyrsa for that matter.

IvanBoyko avatar Dec 19 '19 10:12 IvanBoyko