Chef Infra Client Security
The Chef Infra Server API handles all communication between Chef Infra Client or Chef Workstation. The Chef Infra Server API is an authenticated REST API, which means all requests require authentication and authorization. The Chef Infra tools such as
chef-server commands use the Chef Infra Server API for you.
The authentication process ensures that Chef Infra Server only responds to requests made by trusted users or clients. Chef Infra Server uses public key encryption. You create the public and private keys when you configure Chef Infra Client or setup Chef Workstation.
- Chef Infra Server stores the public key
- Chef Workstation saves the private key in
- Chef Infra Client saves the private key in
Both Chef Infra Client and Chef Workstation communicate with the Chef Infra Server using the Chef Infra Server API. Each time that Chef Infra Client or Chef Workstation makes a request to Chef Infra Server, they use a special group of HTTP headers and sign the rest with their private key. The Chef Infra Server then uses the public key to verify the headers and the contents.
Every request made by Chef Infra Client to the Chef Infra Server must be
an authenticated request using the Chef Infra Server API and a private
key. When Chef Infra Client makes a request to the Chef Infra Server,
Chef Infra Client authenticates each request using a private key located
The private key does not yet exist the first time that Chef Infra Client runs from a new node.
During the first Chef Infra Client run:
- Chef Infra Client uses the chef-validator private key, located in
/etc/chef/validation.pemto register with Chef Infra Server
- Chef Infra Server assigns Chef Infra Client a private key for all future authentication requests to the Chef Infra Server
- Chef Infra Client saves the private key on the node as
If the request to communicate with Chef Infra Server with the chef-validator key fails, then the entire first Chef Infra Client run fails.
After the first completed Chef Infra Client run, delete the chef-validator private key at
Chef Infra Server 12 and later enables SSL verification by default for all requests made to the server, such as those made by knife and Chef Infra Client. The certificate that is generated during the installation of the Chef Infra Server is self-signed, which means the certificate is not signed by a trusted certificate authority (CA) recognized by Chef Infra Client. The certificate generated by the Chef Infra Server must be downloaded to any machine from which knife and/or Chef Infra Client will make requests to the Chef Infra Server.
For example, without downloading the SSL certificate, the following knife command:
knife client list
responds with an error similar to:
ERROR: SSL Validation failure connecting to host: chef-server.example.com ... ERROR: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 ...
This is by design and will occur until a verifiable certificate is added to the machine from which the request is sent.
/.chef/trusted_certs directory stores trusted SSL certificates
used to access the Chef Infra Server:
- On each workstation, this directory is the location into which SScertificates are placed after they are downloaded from the CheInfra Server using the
knife ssl fetchsubcommand
- On every node, this directory is the location into which SSLcertificates are placed when a node has been bootstrapped with ChefInfra Client from a workstation
SSL_CERT_FILE environment variable to specify the location for the SSL certificate authority (CA) bundle for Chef Infra Client.
A value for
SSL_CERT_FILE is not set by default. Unless updated, the locations in which Chef Infra will look for SSL certificates are:
- Chef Infra Client:
- Chef Workstation:
To use a custom CA bundle, update the environment variable to specify the path to the custom CA bundle. The first step to troubleshoot a failing SSL certificate is to verify the location of the
Use following client.rb settings to manage SSL certificate preferences:
||Whether the Chef Infra Server or Chef Infra Client generates the private/public key pair. When
||The file for the OpenSSL key. Chef Infra Client generates this setting automatically.|
||The location of the OpenSSL key file. Chef Infra Client generates this setting automatically.|
||The OpenSSL X.509 certificate for mutual certificate validation. Required for mutual certificate validation on the Chef Infra Server. Default value:
||The OpenSSL X.509 key used for mutual certificate validation. Required for mutual certificate validation on the Chef Infra Server. Default value:
Set the verification mode for HTTPS requests. The recommended setting is
||Verify the SSL certificate on the Chef Infra Server. Set to
The Chef Infra Client includes two knife commands for managing SSL certificates:
- Use knife ssl check to troubleshoot SS certificate issues
- Use knife ssl fetch to pull down a certificate from the Chef Infra Server to the
/.chef/trusted_certsdirectory on the workstation.
After the workstation has the correct SSL certificate, bootstrap operations from that workstation will use the certificate in the
/.chef/trusted_certs directory during the bootstrap operation.
knife ssl check
knife ssl check subcommand to verify the state of the SSL certificate, and then use the response to help troubleshoot issues that may be present.
If the SSL certificate can be verified, the response to
knife ssl check
is similar to:
Connecting to host chef-server.example.com:443 Successfully verified certificates from 'chef-server.example.com'
If the SSL certificate cannot be verified, the response to
knife ssl check
is similar to:
Connecting to host chef-server.example.com:443 ERROR: The SSL certificate of chef-server.example.com could not be verified Certificate issuer data: /C=US/ST=WA/L=S/O=Corp/OU=Ops/CN=chef-server.example.com/emailAddressemail@example.com Configuration Info: OpenSSL Configuration: * Version: OpenSSL 1.0.2u 20 Dec 2019 * Certificate file: /opt/chef-workstation/embedded/ssl/cert.pem * Certificate directory: /opt/chef-workstation/embedded/ssl/certs Chef SSL Configuration: * ssl_ca_path: nil * ssl_ca_file: nil * trusted_certs_dir: "/Users/grantmc/Downloads/chef-repo/.chef/trusted_certs" TO FIX THIS ERROR: If the server you are connecting to uses a self-signed certificate, you must configure chef to trust that certificate. By default, the certificate is stored in the following location on the host where your Chef Infra Server runs: /var/opt/opscode/nginx/ca/SERVER_HOSTNAME.crt Copy that file to your trusted_certs_dir (currently: /Users/grantmc/Downloads/chef-repo/.chef/trusted_certs) using SSH/SCP or some other secure method, then re-run this command to confirm that the certificate is now trusted.
knife ssl fetch
knife ssl fetch to download the self-signed certificate from the Chef Infra Server to the
/.chef/trusted_certs directory on a workstation.
The SSL certificate that is downloaded to the
directory should be verified to ensure that it is, in fact, the same
certificate as the one located on the Chef Infra Server. This can be
done by comparing the SHA-256 checksums.
View the checksum on the Chef Infra Server:
ssh firstname.lastname@example.org sudo sha256sum /var/opt/opscode/nginx/ca/chef-server.example.com.crt
The response is similar to:
View the checksum on the workstation:
The response is similar to:
Verify that the checksum values are identical.
Was this page helpful?