How to create certificates using mkcert on Raspberry Pi for cockpit and configure them on the server (cockpit) and browser
· 2 min read
Operating Environment
The following environment was confirmed for setup.
- Raspberry Pi 5
- AlmaLinux
Meaning of Each Certificate
raspberrypi.pem: Server certificate (public key) This certificate is an SSL certificate issued for the hostnameraspberrypi. Clients such as web browsers use this certificate to verify the authenticity of the server. (This is the one to install on the server)raspberrypi+1.pem: Server certificate (public key) This certificate is an SSL certificate issued for the hostnameraspberrypi <IP address>. Same as above.raspberrypi-key.pem: This is the private key corresponding toraspberrypi.pem. Keep it on the server and use it for SSL encryption/decryption. Never leak it to external parties. (This is the one to install on the server)raspberrypi+1-key.pem: This is the private key corresponding toraspberrypi+1.pem. Keep it on the server and use it for SSL encryption/decryption. Never leak it to external parties. Same as above.rootCA.pem: Local root certificate (public key) This is the certificate of the local CA (Certificate Authority) automatically generated bymkcert. Installing this certificate on the client (browser, etc.) allowsraspberrypi.pemto be treated as a trusted certificate.rootCA-key.pem: Private key of the local CA This is the private key corresponding torootCA.pem, used bymkcertto sign server certificates (e.g.,raspberrypi.pem). It is used internally bymkcertand usually does not need to be touched.
Certificate Issuance
Certificates are issued using the mkcert command. After issuance, they are placed on the server.
mkcert raspberrypi <IP address>
sudo cp raspberrypi+1-key.pem /etc/cockpit/ws-certs.d/raspberrypi.key
sudo cp raspberrypi+1.pem /etc/cockpit/ws-certs.d/raspberrypi.crt
sudo systemctl restart cockpit
Check the location of the local root certificate
Check the location of the root CA certificate to install on the PC.
mkcert -CAROOT
Copy the root certificate to the PC
Copy the root certificate to the PC.
scp raspberrypi:/home/<USER>/ .local/share/mkcert/rootCA.pem .
cp rootCA.pem rootCA.cer
Register the certificate on Windows
Open rootCA.cer and register the certificate in the certificate store under "Trusted Root Certification Authorities".
Register the certificate on Android terminals
Move rootCA.pem to the device and register it in the settings.
