1. Tutorial Goals
By the end of this hands-on tutorial, you will be able to:
- Understand the CODESYS Control for Raspberry Pi 64 SL runtime architecture
- Interpret certificate-related status messages:
CmpWebServer→ no valid certificateCmpOPCUAServer→ no valid certificateCmpSecureChannel→ valid certificate
- Use the runtime command shell effectively
- Generate and manage certificates using
cert-*commands - Enable secure communication for:
- Web Server (HTTPS)
- OPC UA Server (Secure Endpoint)
This tutorial is written as a practical lab, not just theory.
2. Prerequisites
Hardware
- Raspberry Pi (64-bit capable)
- Ethernet or Wi-Fi connectivity
Software
- Raspberry Pi OS 64-bit
- CODESYS Control for Raspberry Pi 64 SL installed and running
- CODESYS Development System (on PC)
- SSH access or local terminal access to the Raspberry Pi
Assumptions
- The runtime is already started
- You can access the CODESYS Runtime Shell (via SSH or local terminal)
3. Understanding the Runtime Components
Before touching certificates, it is important to understand who uses them.
3.1 Key Runtime Components
| Component | Purpose | Certificate Required |
|---|---|---|
CmpSecureChannel | Secure communication with CODESYS IDE | ✅ Yes |
CmpWebServer | Web visualization & device web pages | ✅ Yes (HTTPS) |
CmpOPCUAServer | OPC UA secure communication | ✅ Yes |
3.2 Your Current Status
Web Server (CmpWebServer): CertAvailable = FALSE
OPC UA Server (CmpOPCUAServer): CertAvailable = FALSE
Secure Channel (CmpSecureChannel): CertAvailable = TRUE
✅ This means:
- You can connect from the IDE (secure channel works)
- You cannot use HTTPS web server securely
- You cannot use OPC UA security modes yet
This is a normal fresh-install situation.
4. Accessing the Runtime Command Shell
Log into your Raspberry Pi:
ssh pi@<raspberry_pi_ip>
Then enter the CODESYS runtime shell (usually automatic, or via the service environment).
Test communication:
?
Expected output (similar to yours):
getcmdlist
mem
reflect
applist
…
5. Exploring the Command List
Run:
getcmdlist
5.1 Important Command Groups
Runtime / System
rtsinfocpuloadgettasksgetmulticoreinfo
Application Control
appliststartprgstopprgresetprgresetprgcold
Networking
setinterfaceipdynamicgetinterfaceipdynamic
Logging
logsetfilterloggetfilter
Security & Certificates
cert-getapplistcert-genselfsignedcert-getcertlistcert-createcsrcert-importcert-exportcert-removeshowsecuritysettings
We will now focus on certificates.
6. Inspect Current Security State
Run:
showsecuritysettings
This shows:
- Which components expect certificates
- Which ones already have valid certificates
Typical result (simplified):
- Secure Channel → OK
- Web Server → Missing certificate
- OPC UA Server → Missing certificate
7. Listing Existing Certificates
Run:
cert-getcertlist
Expected outcome:
- One certificate used by
CmpSecureChannel - No certificates for Web Server or OPC UA
This confirms the initial diagnosis.
8. Generating a Self-Signed Certificate (Hands-on)
8.1 Why Self-Signed?
For development, testing, and internal networks, self-signed certificates are perfectly fine.
Later, you can replace them with CA-signed certificates.
8.2 Generate a Self-Signed Certificate
Run:
cert-genselfsigned
You may be prompted for:
- Common Name (CN) → e.g.
codesys-rpi - Organization → optional
- Validity period
✅ This creates:
- A private key
- A certificate stored in the CODESYS certificate store
9. Verifying Certificate Creation
Run again:
cert-getcertlist
You should now see additional certificates.
Also check:
showsecuritysettings
Some components may still show CertAvailable = FALSE until restart.
10. Restarting Runtime Components
Reload runtime configuration:
reload
Or, if needed:
resetprgcold
⚠️ This stops running applications.
After reload, check again:
showsecuritysettings
Expected result:
- Web Server →
CertAvailable = TRUE - OPC UA Server →
CertAvailable = TRUE
11. Enabling HTTPS Web Server (Validation)
- Open a browser
- Navigate to:
You will see a browser warning (self-signed certificate).
✅ This is expected.
Proceed anyway to confirm:
- HTTPS works
- Web server is now secured
12. OPC UA Server Certificate Validation
12.1 In CODESYS IDE
- Add an OPC UA Server configuration
- Enable Sign & Encrypt security policy
- Download configuration to the Raspberry Pi
12.2 Trust Exchange
- Export the server certificate:
cert-export
- Import it into your OPC UA client trust store
Now OPC UA secure sessions should connect successfully.
13. Useful Runtime Monitoring Commands
CPU Load
cpuload
Task Information
gettasks
Active Sessions
sessinfo-list
Real-Time Clock
rtc-get
14. Common Troubleshooting
Web Server Still Not Secure
- Run
cert-getcertlist - Ensure
reloadwas executed - Check
showsecuritysettings
OPC UA Still Fails
- Confirm certificate trust on the client side
- Ensure security policy is not set to
None
Certificate Cleanup
Remove unused certificates:
cert-remove
15. What You Learned
✔ Runtime command shell navigation ✔ Certificate lifecycle in CODESYS ✔ Securing Web Server and OPC UA ✔ Practical use of cert-* commands ✔ Understanding Secure Channel vs services
16. Next Practice Ideas
- Replace self-signed cert with CA-signed cert
- Enable OPC UA user authentication
- Automate certificate deployment
- Combine with firewall rules on Raspberry Pi