Just sharing my findings :
Create a ssl.conf file with the following content :
[ req ]
default_bits = 3072
serial = 0
default_md = sha256
distinguished_name = subject
req_extensions = req_ext
x509_extensions = req_ext
string_mask = utf8only
prompt = no
[ req_ext ]
basicConstraints = critical, CA:false, pathlen:0
keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment, dataEncipherment, keyCertSign
extendedKeyUsage = critical, serverAuth
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer:always
subjectAltName = URI:urn:PFC200V3-48117C:WAGO:WAGO%20750-8210%20PFC200%20G2%204ETH:OPCUA:Server,DNS: PFC200V3-48117C.home,IP:192.168.68.210
[ subject ]
#countryName = YOURCOUNTRYCODE
#stateOrProvinceName = YOURSTATE
#localityName = YOURLOCATION
#organizationName = YOURCOMPANYNAMEHERE
commonName = OPCUAServer@PFC200V3-48117C
The certificate’s subjectAltName must exactly match the name in “Ctrl Configuration Name” in the WBM’s OPC UA tab.
You can also add the hostname or even the IP address in this same field (see configuration below).
Spaces are replaced with “%20”.
Generate private RSA key :
openssl genrsa -out key.pem 3072
Generate server certificate :
openssl req -x509 -days 365 -new -key key.pem -out certificate.pem -config ssl.conf
In case of import via the Security screen, export the server certificate in pkcs12 format (you will need to enter a password because the pfx format contains the private key):
openssl pkcs12 -export -out certificate.pfx -inkey key.pem -in certificate.pem
In the case of importing directly to the controller, export the certificate in der format.
openssl x509 -outform der -in certificate.pem -out certificate.der
The .der file should be named the same as the SHA1 fingerprint of the certificate. To get the SHA1:
openssl x509 -in certificate.der -outform DER | sha1sum
Rename the .der file with the resulting SHA1 fingerprint:
mv certificate.der 47fafffddc0a5851e0d477dd807fc18fb05fa306.der
Transfer the certificate to the PLC, in /home/codesys_root/.pki/own/cert/
Example command in a Linux environment: :
scp 47fafffddc0a5851e0d477dd807fc18fb05fa306.der root@192.168.68.203:/home/codesys_root/.pki/own/cert/
Check the permissions on the certificate. Certificates must have the following rights in the folder /home/codesys_root/.pki/own/cert : -rw-rw-r–
ls -l root@192.168.68.203:/home/codesys_root/.pki/own/cert/
Example results:
-rw-rw-r-- 1 root admin 942 Oct 10 14:03 3c92967425b62f6a177c9e058e3ff1a43b3a4450.der
-rw-r–r-- 1 root admin 1288 Oct 22 09:02 47fafffddc0a5851e0d477dd807fc18fb05fa306.der
to give the correct permissions:
chmod 664 47fafffddc0a5851e0d477dd807fc18fb05fa306.der
ls -l root@192.168.68.203:/home/codesys_root/.pki/own/cert/
Example results:
-rw-rw-r-- 1 root admin 942 Oct 10 14:03 3c92967425b62f6a177c9e058e3ff1a43b3a4450.der
-rw-rw-r-- 1 root admin 1288 Oct 22 09:02 47fafffddc0a5851e0d477dd807fc18fb05fa306.der
To verify that the certificates are recognized as OPC UA certificates in CODESYS, open the Security screen in CODESYS.
In the Devices tab, click on the Device. The OPC UA Server must have a certificate. If it doesn’t, it means the certificate doesn’t comply with the rules above.
We can also ensure that after connecting to UAexpert there is no new certificate in the quarantine: this would indicate that the certificate configured in UAexpert does not correspond to the one added in the Trusted section (trustworthy certificates).
I’ve not been able to generate the client (Uaexpert) certificate.
If someone find a way I’m interested