You achieve the know-how protection and copy protection of a boot application with the help of PLC -specific license management and its settings in the object properties of the application. The download code and the boot application can be encrypted and signed.
Requirements: You have a project with an application that you want to download to the controller as an encrypted boot application. In the Windows Certificate Store of your computer, you have a certificate of this controller for encrypting the application. Note: In case you want to download the application to different controllers, you will need the appropriate certificate for each controller.
-
Select the application in the device tree.
-
In the context menu, click Properties.
The Properties – <application name> dialog opens.
-
Click the Security tab.
-
On Encryption Technology, select the Encryption with certificates option.
The Certificates group is enabled.
-
If there are not any certificates listed in the table, then click the
button.The Certificate Selection dialog opens for selecting a certificate from the local Windows Certificate Store.
-
In the lower area, select a certificate and add it to the upper area by clicking the
button. Click OK to confirm.The certificate is shown in the Certificates group of the Encryption dialog.
-
Note: If you want to sign the boot application as well, then you can proceed as follows: Select the Digitally sign application code option in the properties dialog and follow Steps 1–13 of the "Signing the boot application only with a certificate (no encryption)" instructions below.
For more information, see: Encrypting a project with a certificate
|
Important |
|---|---|
|
Encryption with a dongle is no longer classified as a secure encryption method. It is recommended to encrypt with certificates instead. |
Requirements: You have a project with an application that you want to download to the controller as an encrypted boot application. A security key for license management is connected to your computer.
-
Select the application in the device tree.
-
In the context menu, click Properties.
The Properties – <application name> dialog opens.
-
Click the Security tab.
-
For Encryption Technology, select the Simple Encryption option and type the Product code that you received from the hardware manufacturer for the controller. Depending on the controller, it is protected either by a security key (firm code is shown automatically) or by an integrated Wibu SD card for example.
-
Click and download the application.
If the matching security key and/or valid license is available, then you can download the application to the controller. By default, a boot application is automatically created at this time in the controller directory. The default setting is defined in the application Properties, in the Boot Application category.
-
Log out, change the application, and log in again.
You are prompted to perform an online change. The dialog provides the option of updating the boot application on the PLC. If the security key and license match, then you can log in. If not, then you receive a corresponding message.
-
In the status bar of CODESYS, click the
button to open the Security Screen view. Then select a certificate with a private key for a user profile for the Digital Signature. The procedure is described in the instructions "Configuring a certificate for the digital signature in a user profile". -
Double-click the certificate for the Digital Signature on the User tab.
The Certificate dialog opens.
-
On the Details tab, click Copy to file.
The Certificate Export Wizard starts.
-
In the Export Private Key prompt, select the No, do not export the private key option.
-
For Export File Format, select the DER encoded binary X.509 (.CER) option.
-
In the next step, select a file name and the location for the certificate.
-
After the last step Finish, a message appears that the export was successful.
-
After successful export to CODESYS, double-click the controller in the device tree to open the device editor and select the Files tab for the file transfer.
-
Select the Path
cert/importin the right side of the Runtime dialog. -
On the left side of the dialog for Host, select the path in the file system where you saved the exported certificate and selected the certificate.
-
Click
.The certificate is copied to the
cert/importfolder. -
Click the PLC Shell tab.
-
In the input line of the tab, specify the
cert-import trusted <file name.cer>command and press the Enter key. Note that the file name is specified with the extension.cer; otherwise the certificate is not imported successfully.The certificate is created on the controller under
trusted. With this certificate, the controller can test the integrity of the boot application. -
In the status bar, double-click
to open the Security Screen view.On the Users tab, make sure that the Enforce encryption of downloads, online changes and boot applications protection option is not selected.
-
In the Security-Eigenschaften of the application, select the Sign with certificate option. To do this, open the properties dialog for example in the Security Screen view on the Project tab. Double-click there in the lower part of the window on the entry for the application.
Note: If the Enforce signing of downloads, online changes and boot applications option which applies to all projects is selected in the Security Screen view, then the Sign with certificate option is already selected.
You will be able to transfer the application to the controller only if the certificate used for signing is valid.
Requirement: The CODESYS Security Agent add-on product is installed.
The Security Screen view provides an additional tab: Devices. This allows for the configuration of certificates for the encrypted communication with controllers. In this case, see the help for CODESYS Security Agent.
Alternatives:
If you the CODESYS Security Agent is not available to you, then you can proceed as follows by means of the PLC shell of the device editor:
In order to use certificates on the controller for the encryption of downloads, online changes, and boot applications, these certificates first have to be generated on the controller and loaded from the controller and installed in the Windows Certificate Store.
Requirement: You are connected to the controller.
-
Open the device editor by double-clicking the controller in the device tree, and select the PLC Shell tab.
The tab is displayed with an empty window. Below that is a command line.
-
Type
?in the command line and press the Enter key.All commands are listed in the display window.
-
Specify the
cert-getapplistcommand in the command line.All used certificates are listed with information about components and availability with certificates.
-
If no certificate is available for the
CmpAppcomponent, then type the commandcert-genselfsigned <number of the component in the applist>. -
Click the Log tab and then click the
refresh button.The display shows whether or not the certificate was generated successfully.
-
Specify
cert-getcertlistand press the Enter key.Your own certificates are listed that can be used for encryption. The
NumberandKey usage(s)information is useful in the next step.Number: The number is specified as a parameter in the next step.Key usage(s): Data encryptionmeans that this is a certificate of the controller for a download, online change, and boot application. -
Export the required certificate by typing in the command
cert-export own 0and press the Enter key.0is theNumberof the certificate withKey usage(s):Data encryption.The display shows that the certificate has been exported to a
certdirectory. -
Click the Files tab of the device editor.
-
In the right part of the dialog in Runtime, click the
refresh button.The list of files and directories is refreshed.
-
Open the cert folder in the list and then the export subfolder.
-
In the left part of the dialog in Host, open the directory where the certificate of the controller will be loaded.
-
In the right part of the dialog, select the certificate that you have exported and click
.The certificate is copied to the selected directory.
-
In the file explorer, go to the directory where the certificate was copied and double-click the certificate.
The Certificate dialog opens and shows the information about this certificate.
-
On the General tab, click Install Certificate.
The Certificate Import Wizard starts.
-
In the Certificate Storage dialog, for Certificate Import Wizard, select the Store all certificates in the following store option and then select the Controller Certificates folder.
The controller certificate is imported into the Windows Certificate Store in the Controller Certificates folder. Now the certificate is available for the encryption of boot applications, downloads, and online changes.
-
In the status bar, double-click
to open the Security Screen. -
If you want that downloads, online changes, and boot applications of your project are always encrypted, then select the Enforce encryption of downloads, online changes and boot applications option in the Security level group on the User tab.
-
Open the Project tab and double-click the application in the Encryption of boot application, download and online change area.
The properties dialog of the application opens.
-
Click the Security tab, select Encryption with certificates in the Encryption technology list box, and click
.Note: If the Enforce encryption of downloads, online changes and boot applications option which applies to all projects is selected in the Security Screen, then Encryption with certificates is already selected.
-
In the Certificate Selection dialog, select the respective certificate from the Controller Certificates folder and click
. -
Click OK to confirm the dialog.
The certificate is displayed in the properties dialog.
-
Confirm the properties dialog of the application.
The certificate is shown on the Project tab of the Security Screen in the Encryption of boot application, download and online change group.
The boot application, download, and online change are encrypted.
Requirement: The CODESYS Security Agent add-on product is installed. A certificate with the information "Encrypted Application" is already installed on your computer.
-
In the Security Screen view, on the Project tab, in the bottom view, click the entry for the application.
The Properties dialog for the application opens with the Encryption tab.
-
For Encryption Technology, select Encryption with certificates. In the Certificates group, click
. -
In the Certificate Selection dialog, delete the certificate as described above.
-
Click OK to close the Certificate Selection dialog.
The certificate is no longer displayed in the Properties dialog.