1

I'm trying to implement Encryption for my "open62541" Server which i connect with the UaExpert-Client. First i created the self signed certificate with the "create_self-signed.py". After i executed the .py-file with the information of the output-path, i got the "server_cert.der" and "server_key.der". I tried to modify the server config, but i'm note sure which method i have to use. Could someone tell me where to put those ".der files" and which methods should i use to modify my server-config?

opc_rookie
  • 37
  • 2
  • 6

1 Answers1

0

There's a whole example on how to use encryption: https://github.com/open62541/open62541/blob/master/examples/encryption/server_encryption.c

Always check the examples directory of any open source project. There you will find a lot of nice code samples.

An excerpt of the code is here:

    /* Load certificate and private key */
    UA_ByteString certificate = loadFile(argv[1]);
    UA_ByteString privateKey = loadFile(argv[2]);

    /* Load the trustlist */
    size_t trustListSize = 0;
    if(argc > 3)
        trustListSize = (size_t)argc-3;
    UA_STACKARRAY(UA_ByteString, trustList, trustListSize);
    for(size_t i = 0; i < trustListSize; i++)
        trustList[i] = loadFile(argv[i+3]);

    /* Loading of a issuer list, not used in this application */
    size_t issuerListSize = 0;
    UA_ByteString *issuerList = NULL;

    /* Loading of a revocation list currently unsupported */
    UA_ByteString *revocationList = NULL;
    size_t revocationListSize = 0;

    UA_Server *server = UA_Server_new();
    UA_ServerConfig *config = UA_Server_getConfig(server);

    UA_StatusCode retval =
        UA_ServerConfig_setDefaultWithSecurityPolicies(config, 4840,
                                                       &certificate, &privateKey,
                                                       trustList, trustListSize,
                                                       issuerList, issuerListSize,
                                                       revocationList, revocationListSize);
Stefan Profanter
  • 6,458
  • 6
  • 41
  • 73