Self-signed certificates
There are many tools available to generate self-signed certificates.
OpenSSL
Here is an example of how to use OpenSSL to generate self-signed x509 v3 certificates. This example works on Linux. Anyway, OpenSSL is available on Windows platform as well.
Install OpenSSL if it is not installed yet:
Create cert.cnf with the following content:
Fill [req_distinguished_name] and [alt_names] sections appropriately. As a recomendation, CN should refer to target device. Take into account, DNS and IP are validated by client when esteblishing a connection to OPCUA server.
Generate private key:
Now, generate self-signed certificate.
As a result, two files are created. my.key is a private key file which should be kept in secret and my.cert is a certificate file. Both are in PEM format.
Use the following command to display certificate content:
PowerShell
Here is an example of how to use PowerShell scripts to generate self-signed x509 v3 certificates. Take into account, proposed example works with PowerShell 7.1 and higher.
Define certificate subject, DNS name and certificate location:
Generate self-signed certificate:
Export certificate to PEM format:
Export private key:
As a result, two files are created. my.key is a private key file which should be kept in secret and my.cert is a certificate file. Both are in PEM format.
Use the following OpenSSL command to display certificate content: