Browse Source

Client: Initialize client config inside the client structure

Temporarily disable encyrption
Julius Pfrommer 5 years ago
parent
commit
b4c9fc37eb
34 changed files with 295 additions and 657 deletions
  1. 2 1
      README.md
  2. 0 3
      examples/CMakeLists.txt
  3. 3 1
      examples/access_control/client_access_control.c
  4. 2 1
      examples/client.c
  5. 2 1
      examples/client_async.c
  6. 5 3
      examples/client_connect_loop.c
  7. 5 7
      examples/client_connectivitycheck_loop.c
  8. 2 1
      examples/client_historical.c
  9. 6 5
      examples/client_subscription_loop.c
  10. 6 5
      examples/custom_datatype/client_types_custom.c
  11. 6 3
      examples/discovery/client_find_servers.c
  12. 2 1
      examples/discovery/server_register.c
  13. 0 156
      examples/encryption/client_basic128rsa15.c
  14. 0 156
      examples/encryption/client_basic256sha256.c
  15. 2 1
      examples/tutorial_client_events.c
  16. 2 1
      examples/tutorial_client_firststeps.c
  17. 1 21
      include/ua_client.h
  18. 54 27
      plugins/ua_config_default.c
  19. 2 1
      plugins/ua_config_default.h
  20. 5 118
      src/client/ua_client.c
  21. 30 23
      tests/client/check_client.c
  22. 27 32
      tests/client/check_client_async.c
  23. 10 9
      tests/client/check_client_async_connect.c
  24. 2 1
      tests/client/check_client_highlevel.c
  25. 2 1
      tests/client/check_client_historical_data.c
  26. 23 9
      tests/client/check_client_securechannel.c
  27. 23 12
      tests/client/check_client_subscriptions.c
  28. 9 9
      tests/encryption/check_encryption_basic128rsa15.c
  29. 9 9
      tests/encryption/check_encryption_basic256sha256.c
  30. 31 28
      tests/server/check_accesscontrol.c
  31. 16 8
      tests/server/check_discovery.c
  32. 2 1
      tests/server/check_monitoreditem_filter.c
  33. 2 1
      tests/server/check_server_historical_data.c
  34. 2 1
      tests/server/check_services_view.c

+ 2 - 1
README.md

@@ -173,7 +173,8 @@ int main(int argc, char** argv)
 int main(int argc, char *argv[])
 {
     /* Create a client and connect */
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode status = UA_Client_connect(client, "opc.tcp://localhost:4840");
     if(status != UA_STATUSCODE_GOOD) {
         UA_Client_delete(client);

+ 0 - 3
examples/CMakeLists.txt

@@ -122,9 +122,6 @@ endif()
 if(UA_ENABLE_ENCRYPTION)
     add_example(server_basic128rsa15 encryption/server_basic128rsa15.c)
     add_example(server_basic256sha256 encryption/server_basic256sha256.c)
-    # Add secure client example application
-    add_example(client_basic128rsa15 encryption/client_basic128rsa15.c)
-    add_example(client_basic256sha256 encryption/client_basic256sha256.c)
 endif()
 
 add_example(custom_datatype_client custom_datatype/client_types_custom.c)

+ 3 - 1
examples/access_control/client_access_control.c

@@ -10,7 +10,9 @@
 #include <ua_client_highlevel.h>
 
 int main(void) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     if(retval != UA_STATUSCODE_GOOD) {
         UA_Client_delete(client);

+ 2 - 1
examples/client.c

@@ -27,7 +27,8 @@ nodeIter(UA_NodeId childId, UA_Boolean isInverse, UA_NodeId referenceTypeId, voi
 }
 
 int main(int argc, char *argv[]) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
 
     /* Listing endpoints */
     UA_EndpointDescription* endpointArray = NULL;

+ 2 - 1
examples/client_async.c

@@ -102,7 +102,8 @@ translateCalled(UA_Client *client, void *userdata, UA_UInt32 requestId,
 
 int
 main(int argc, char *argv[]) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_UInt32 reqId = 0;
     UA_String userdata = UA_STRING("userdata");
 

+ 5 - 3
examples/client_connect_loop.c

@@ -27,10 +27,12 @@ static void stopHandler(int sign) {
 int main(void) {
     signal(SIGINT, stopHandler); /* catches ctrl-c */
 
-    UA_ClientConfig config = UA_ClientConfig_default;
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig *cc = UA_Client_getConfig(client);
+    UA_ClientConfig_setDefault(cc);
+
     /* default timeout is 5 seconds. Set it to 1 second here for demo */
-    config.timeout = 1000;
-    UA_Client *client = UA_Client_new(config);
+    cc->timeout = 1000;
 
     /* Read the value attribute of the node. UA_Client_readValueAttribute is a
      * wrapper for the raw read service available as UA_Client_Service_read. */

+ 5 - 7
examples/client_connectivitycheck_loop.c

@@ -22,14 +22,12 @@ inactivityCallback (UA_Client *client) {
 int main(void) {
     signal(SIGINT, stopHandler); /* catches ctrl-c */
 
-    UA_ClientConfig config = UA_ClientConfig_default;
-    /* Set stateCallback */
-    config.inactivityCallback = inactivityCallback;
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig *cc = UA_Client_getConfig(client);
+    UA_ClientConfig_setDefault(cc);
 
-    /* Perform a connectivity check every 2 seconds */
-    config.connectivityCheckInterval = 2000;
-
-    UA_Client *client = UA_Client_new(config);
+    cc->inactivityCallback = inactivityCallback; /* Set stateCallback */
+    cc->connectivityCheckInterval = 2000; /* Perform a connectivity check every 2 seconds */
 
     /* Endless loop runAsync */
     while (running) {

+ 2 - 1
examples/client_historical.c

@@ -133,7 +133,8 @@ readHist(UA_Client *client, const UA_NodeId *nodeId,
 }
 
 int main(int argc, char *argv[]) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
 
     /* Connect to the Unified Automation demo server */
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:53530/OPCUA/SimulationServer");

+ 6 - 5
examples/client_subscription_loop.c

@@ -108,12 +108,13 @@ int
 main(void) {
     signal(SIGINT, stopHandler); /* catches ctrl-c */
 
-    UA_ClientConfig config = UA_ClientConfig_default;
-    /* Set stateCallback */
-    config.stateCallback = stateCallback;
-    config.subscriptionInactivityCallback = subscriptionInactivityCallback;
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig *cc = UA_Client_getConfig(client);
+    UA_ClientConfig_setDefault(cc);
 
-    UA_Client *client = UA_Client_new(config);
+    /* Set stateCallback */
+    cc->stateCallback = stateCallback;
+    cc->subscriptionInactivityCallback = subscriptionInactivityCallback;
 
     /* Endless loop runAsync */
     while(running) {

+ 6 - 5
examples/custom_datatype/client_types_custom.c

@@ -6,18 +6,19 @@
 #include "custom_datatype.h"
 
 int main(void) {
-    UA_ClientConfig config = UA_ClientConfig_default;
-
     /* Make your custom datatype known to the stack */
     UA_DataType types[1];
     types[0] = PointType;
 
     /* Attention! Here the custom datatypes are allocated on the stack. So they
      * cannot be accessed from parallel (worker) threads. */
-    UA_DataTypeArray customDataTypes = {config.customDataTypes, 1, types};
-    config.customDataTypes = &customDataTypes;
+    UA_DataTypeArray customDataTypes = {NULL, 1, types};
+
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig *cc = UA_Client_getConfig(client);
+    UA_ClientConfig_setDefault(cc);
+    cc->customDataTypes = &customDataTypes;
 
-    UA_Client *client = UA_Client_new(config);
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     if(retval != UA_STATUSCODE_GOOD) {
         UA_Client_delete(client);

+ 6 - 3
examples/discovery/client_find_servers.c

@@ -21,7 +21,8 @@ int main(void) {
         UA_ServerOnNetwork *serverOnNetwork = NULL;
         size_t serverOnNetworkSize = 0;
 
-        UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+        UA_Client *client = UA_Client_new();
+        UA_ClientConfig_setDefault(UA_Client_getConfig(client));
         UA_StatusCode retval = UA_Client_findServersOnNetwork(client, DISCOVERY_SERVER_ENDPOINT, 0, 0,
                                                               0, NULL, &serverOnNetworkSize, &serverOnNetwork);
         if(retval != UA_STATUSCODE_GOOD) {
@@ -59,7 +60,8 @@ int main(void) {
 
     UA_StatusCode retval;
     {
-        UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+        UA_Client *client = UA_Client_new();
+        UA_ClientConfig_setDefault(UA_Client_getConfig(client));
         retval = UA_Client_findServers(client, DISCOVERY_SERVER_ENDPOINT, 0, NULL, 0, NULL,
                                        &applicationDescriptionArraySize, &applicationDescriptionArray);
         UA_Client_delete(client);
@@ -126,7 +128,8 @@ int main(void) {
         printf("\nEndpoints for Server[%lu]: %.*s\n", (unsigned long) i,
                (int) description->applicationUri.length, description->applicationUri.data);
 
-        UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+        UA_Client *client = UA_Client_new();
+        UA_ClientConfig_setDefault(UA_Client_getConfig(client));
 
         char *discoveryUrl = (char *) UA_malloc(sizeof(char) * description->discoveryUrls[0].length + 1);
         memcpy(discoveryUrl, description->discoveryUrls[0].data, description->discoveryUrls[0].length);

+ 2 - 1
examples/discovery/server_register.c

@@ -90,7 +90,8 @@ int main(int argc, char **argv) {
                                         myIntegerName, UA_NODEID_NULL, attr, dateDataSource,
                                         &myInteger, NULL);
 
-    UA_Client *clientRegister = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *clientRegister = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(clientRegister));
 
     // periodic server register after 10 Minutes, delay first register for 500ms
     UA_StatusCode retval =

+ 0 - 156
examples/encryption/client_basic128rsa15.c

@@ -1,156 +0,0 @@
-/* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
- * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
-
-#include <ua_server.h>
-#include <ua_config_default.h>
-#include <ua_log_stdout.h>
-#include <ua_securitypolicies.h>
-#include <ua_client_highlevel.h>
-#include "common.h"
-
-#include <signal.h>
-
-#define MIN_ARGS           3
-#define FAILURE            1
-#define CONNECTION_STRING  "opc.tcp://localhost:4840"
-
-/* cleanupClient deletes the memory allocated for client configuration.
- *
- * @param  client             client configuration that need to be deleted
- * @param  remoteCertificate  server certificate */
-static void cleanupClient(UA_Client* client, UA_ByteString* remoteCertificate) {
-    UA_ByteString_delete(remoteCertificate);
-    UA_Client_delete(client); /* Disconnects the client internally */
-}
-
-/* main function for secure client implementation.
- *
- * @param  argc               count of command line variable provided
- * @param  argv[]             array of strings include certificate, private key,
- *                            trust list and revocation list
- * @return Return an integer representing success or failure of application */
-int main(int argc, char* argv[]) {
-    UA_Client*              client             = NULL;
-    UA_ByteString*          remoteCertificate  = NULL;
-    UA_StatusCode           retval             = UA_STATUSCODE_GOOD;
-    size_t                  trustListSize      = 0;
-    UA_ByteString*          revocationList     = NULL;
-    size_t                  revocationListSize = 0;
-
-    /* endpointArray is used to hold the available endpoints in the server
-     * endpointArraySize is used to hold the number of endpoints available */
-    UA_EndpointDescription* endpointArray      = NULL;
-    size_t                  endpointArraySize  = 0;
-
-    if(argc < MIN_ARGS) {
-        UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
-                     "The Certificate and key is missing."
-                     "The required arguments are "
-                     "<client-certificate.der> <client-private-key.der> "
-                     "[<trustlist1.crl>, ...]");
-        return FAILURE;
-    }
-
-    /* Load certificate and private key */
-    UA_ByteString           certificate        = loadFile(argv[1]);
-    UA_ByteString           privateKey         = loadFile(argv[2]);
-
-    /* The Get endpoint (discovery service) is done with
-     * security mode as none to see the server's capability
-     * and certificate */
-    client = UA_Client_new(UA_ClientConfig_default);
-    remoteCertificate = UA_ByteString_new();
-    retval = UA_Client_getEndpoints(client, CONNECTION_STRING,
-                                    &endpointArraySize, &endpointArray);
-    if(retval != UA_STATUSCODE_GOOD) {
-        UA_Array_delete(endpointArray, endpointArraySize,
-                        &UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION]);
-        cleanupClient(client, remoteCertificate);
-        return (int)retval;
-    }
-
-    UA_String securityPolicyUri = UA_STRING("http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15");
-    printf("%i endpoints found\n", (int)endpointArraySize);
-    for(size_t endPointCount = 0; endPointCount < endpointArraySize; endPointCount++) {
-        printf("URL of endpoint %i is %.*s / %.*s\n", (int)endPointCount,
-               (int)endpointArray[endPointCount].endpointUrl.length,
-               endpointArray[endPointCount].endpointUrl.data,
-               (int)endpointArray[endPointCount].securityPolicyUri.length,
-               endpointArray[endPointCount].securityPolicyUri.data);
-
-        if(endpointArray[endPointCount].securityMode != UA_MESSAGESECURITYMODE_SIGNANDENCRYPT)
-            continue;
-
-        if(UA_String_equal(&endpointArray[endPointCount].securityPolicyUri, &securityPolicyUri)) {
-            UA_ByteString_copy(&endpointArray[endPointCount].serverCertificate, remoteCertificate);
-            break;
-        }
-    }
-
-    if(UA_ByteString_equal(remoteCertificate, &UA_BYTESTRING_NULL)) {
-        UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
-                     "Server does not support Security Basic128Rsa15 Mode of"
-                     " UA_MESSAGESECURITYMODE_SIGNANDENCRYPT");
-        cleanupClient(client, remoteCertificate);
-        return FAILURE;
-    }
-
-    UA_Array_delete(endpointArray, endpointArraySize,
-                    &UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION]);
-
-    UA_Client_delete(client); /* Disconnects the client internally */
-
-    /* Load the trustList. Load revocationList is not supported now */
-    if(argc > MIN_ARGS)
-        trustListSize = (size_t)argc-MIN_ARGS;
-
-    UA_STACKARRAY(UA_ByteString, trustList, trustListSize);
-    for(size_t trustListCount = 0; trustListCount < trustListSize; trustListCount++) {
-        trustList[trustListCount] = loadFile(argv[trustListCount+3]);
-    }
-
-    /* Secure client initialization */
-    client = UA_Client_secure_new(UA_ClientConfig_default,
-                                  certificate, privateKey,
-                                  remoteCertificate,
-                                  trustList, trustListSize,
-                                  revocationList, revocationListSize,
-                                  UA_SecurityPolicy_Basic128Rsa15);
-    if(client == NULL) {
-        UA_ByteString_delete(remoteCertificate);
-        return FAILURE;
-    }
-
-    UA_ByteString_clear(&certificate);
-    UA_ByteString_clear(&privateKey);
-    for(size_t deleteCount = 0; deleteCount < trustListSize; deleteCount++) {
-        UA_ByteString_clear(&trustList[deleteCount]);
-    }
-
-    /* Secure client connect */
-    retval = UA_Client_connect(client, CONNECTION_STRING);
-    if(retval != UA_STATUSCODE_GOOD) {
-        cleanupClient(client, remoteCertificate);
-        return (int)retval;
-    }
-
-    UA_Variant value;
-    UA_Variant_init(&value);
-
-    /* NodeId of the variable holding the current time */
-    const UA_NodeId nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME);
-    retval = UA_Client_readValueAttribute(client, nodeId, &value);
-
-    if(retval == UA_STATUSCODE_GOOD &&
-       UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_DATETIME])) {
-        UA_DateTime raw_date  = *(UA_DateTime *) value.data;
-        UA_DateTimeStruct dts = UA_DateTime_toStruct(raw_date);
-        UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "date is: %u-%u-%u %u:%u:%u.%03u\n",
-                    dts.day, dts.month, dts.year, dts.hour, dts.min, dts.sec, dts.milliSec);
-    }
-
-    /* Clean up */
-    UA_Variant_clear(&value);
-    cleanupClient(client, remoteCertificate);
-    return (int)retval;
-}

+ 0 - 156
examples/encryption/client_basic256sha256.c

@@ -1,156 +0,0 @@
-/* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
- * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
-
-#include <ua_server.h>
-#include <ua_config_default.h>
-#include <ua_log_stdout.h>
-#include <ua_securitypolicies.h>
-#include <ua_client_highlevel.h>
-#include "common.h"
-
-#include <signal.h>
-
-#define MIN_ARGS           3
-#define FAILURE            1
-#define CONNECTION_STRING  "opc.tcp://localhost:4840"
-
-/* cleanupClient deletes the memory allocated for client configuration.
- *
- * @param  client             client configuration that need to be deleted
- * @param  remoteCertificate  server certificate */
-static void cleanupClient(UA_Client* client, UA_ByteString* remoteCertificate) {
-    UA_ByteString_delete(remoteCertificate);
-    UA_Client_delete(client); /* Disconnects the client internally */
-}
-
-/* main function for secure client implementation.
- *
- * @param  argc               count of command line variable provided
- * @param  argv[]             array of strings include certificate, private key,
- *                            trust list and revocation list
- * @return Return an integer representing success or failure of application */
-int main(int argc, char* argv[]) {
-    UA_Client*              client             = NULL;
-    UA_ByteString*          remoteCertificate  = NULL;
-    UA_StatusCode           retval             = UA_STATUSCODE_GOOD;
-    size_t                  trustListSize      = 0;
-    UA_ByteString*          revocationList     = NULL;
-    size_t                  revocationListSize = 0;
-
-    /* endpointArray is used to hold the available endpoints in the server
-     * endpointArraySize is used to hold the number of endpoints available */
-    UA_EndpointDescription* endpointArray      = NULL;
-    size_t                  endpointArraySize  = 0;
-
-    if(argc < MIN_ARGS) {
-        UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
-                     "The Certificate and key is missing."
-                     "The required arguments are "
-                     "<client-certificate.der> <client-private-key.der> "
-                     "[<trustlist1.crl>, ...]");
-        return FAILURE;
-    }
-
-    /* Load certificate and private key */
-    UA_ByteString           certificate        = loadFile(argv[1]);
-    UA_ByteString           privateKey         = loadFile(argv[2]);
-
-    /* The Get endpoint (discovery service) is done with
-     * security mode as none to see the server's capability
-     * and certificate */
-    client = UA_Client_new(UA_ClientConfig_default);
-    remoteCertificate = UA_ByteString_new();
-    retval = UA_Client_getEndpoints(client, CONNECTION_STRING,
-                                    &endpointArraySize, &endpointArray);
-    if(retval != UA_STATUSCODE_GOOD) {
-        UA_Array_delete(endpointArray, endpointArraySize,
-                        &UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION]);
-        cleanupClient(client, remoteCertificate);
-        return (int)retval;
-    }
-
-    UA_String securityPolicyUri = UA_STRING("http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256");
-    printf("%i endpoints found\n", (int)endpointArraySize);
-    for(size_t endPointCount = 0; endPointCount < endpointArraySize; endPointCount++) {
-        printf("URL of endpoint %i is %.*s / %.*s\n", (int)endPointCount,
-               (int)endpointArray[endPointCount].endpointUrl.length,
-               endpointArray[endPointCount].endpointUrl.data,
-               (int)endpointArray[endPointCount].securityPolicyUri.length,
-               endpointArray[endPointCount].securityPolicyUri.data);
-
-        if(endpointArray[endPointCount].securityMode != UA_MESSAGESECURITYMODE_SIGNANDENCRYPT)
-            continue;
-
-        if(UA_String_equal(&endpointArray[endPointCount].securityPolicyUri, &securityPolicyUri)) {
-            UA_ByteString_copy(&endpointArray[endPointCount].serverCertificate, remoteCertificate);
-            break;
-        }
-    }
-
-    if(UA_ByteString_equal(remoteCertificate, &UA_BYTESTRING_NULL)) {
-        UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
-                     "Server does not support Security Basic256Sha256 Mode of"
-                     " UA_MESSAGESECURITYMODE_SIGNANDENCRYPT");
-        cleanupClient(client, remoteCertificate);
-        return FAILURE;
-    }
-
-    UA_Array_delete(endpointArray, endpointArraySize,
-                    &UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION]);
-
-    UA_Client_delete(client); /* Disconnects the client internally */
-
-    /* Load the trustList. Load revocationList is not supported now */
-    if(argc > MIN_ARGS)
-        trustListSize = (size_t)argc-MIN_ARGS;
-
-    UA_STACKARRAY(UA_ByteString, trustList, trustListSize);
-    for(size_t trustListCount = 0; trustListCount < trustListSize; trustListCount++) {
-        trustList[trustListCount] = loadFile(argv[trustListCount+3]);
-    }
-
-    /* Secure client initialization */
-    client = UA_Client_secure_new(UA_ClientConfig_default,
-                                  certificate, privateKey,
-                                  remoteCertificate,
-                                  trustList, trustListSize,
-                                  revocationList, revocationListSize,
-                                  UA_SecurityPolicy_Basic256Sha256);
-    if(client == NULL) {
-        UA_ByteString_delete(remoteCertificate);
-        return FAILURE;
-    }
-
-    UA_ByteString_clear(&certificate);
-    UA_ByteString_clear(&privateKey);
-    for(size_t deleteCount = 0; deleteCount < trustListSize; deleteCount++) {
-        UA_ByteString_clear(&trustList[deleteCount]);
-    }
-
-    /* Secure client connect */
-    retval = UA_Client_connect(client, CONNECTION_STRING);
-    if(retval != UA_STATUSCODE_GOOD) {
-        cleanupClient(client, remoteCertificate);
-        return (int)retval;
-    }
-
-    UA_Variant value;
-    UA_Variant_init(&value);
-
-    /* NodeId of the variable holding the current time */
-    const UA_NodeId nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME);
-    retval = UA_Client_readValueAttribute(client, nodeId, &value);
-
-    if(retval == UA_STATUSCODE_GOOD &&
-       UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_DATETIME])) {
-        UA_DateTime raw_date  = *(UA_DateTime *) value.data;
-        UA_DateTimeStruct dts = UA_DateTime_toStruct(raw_date);
-        UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "date is: %u-%u-%u %u:%u:%u.%03u\n",
-                    dts.day, dts.month, dts.year, dts.hour, dts.min, dts.sec, dts.milliSec);
-    }
-
-    /* Clean up */
-    UA_Variant_clear(&value);
-    cleanupClient(client, remoteCertificate);
-    return (int)retval;
-}

+ 2 - 1
examples/tutorial_client_events.c

@@ -102,7 +102,8 @@ int main(int argc, char *argv[]) {
         return 1;
     }
 
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
 
     /* opc.tcp://uademo.prosysopc.com:53530/OPCUA/SimulationServer */
     /* opc.tcp://opcua.demo-this.com:51210/UA/SampleServer */

+ 2 - 1
examples/tutorial_client_firststeps.c

@@ -13,7 +13,8 @@
 #include <ua_log_stdout.h>
 
 int main(void) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     if(retval != UA_STATUSCODE_GOOD) {
         UA_Client_delete(client);

+ 1 - 21
include/ua_client.h

@@ -53,27 +53,7 @@ _UA_BEGIN_DECLS
 
 /* Create a new client */
 UA_Client UA_EXPORT *
-UA_Client_new(UA_ClientConfig config);
-
-/* Creates a new secure client with the required configuration, certificate
- * privatekey, trustlist and revocation list.
- *
- * @param  config                   new secure configuration for client
- * @param  certificate              client certificate
- * @param  privateKey               client's private key
- * @param  remoteCertificate        server certificate form the endpoints
- * @param  trustList                list of trustable certificate
- * @param  trustListSize            count of trustList
- * @param  revocationList           list of revoked digital certificate
- * @param  revocationListSize       count of revocationList
- * @param  securityPolicyFunction   securityPolicy function
- * @return Returns a client configuration for secure channel */
-UA_Client UA_EXPORT *
-UA_Client_secure_new(UA_ClientConfig config, UA_ByteString certificate,
-                     UA_ByteString privateKey, const UA_ByteString *remoteCertificate,
-                     const UA_ByteString *trustList, size_t trustListSize,
-                     const UA_ByteString *revocationList, size_t revocationListSize,
-                     UA_SecurityPolicy_Func securityPolicyFunction);
+UA_Client_new(void);
 
 /* Get the client connection status */
 UA_ClientState UA_EXPORT

+ 54 - 27
plugins/ua_config_default.c

@@ -743,33 +743,60 @@ static UA_INLINE void UA_ClientConnectionTCP_poll_callback(UA_Client *client, vo
     UA_ClientConnectionTCP_poll(client, data);
 }
 
-const UA_ClientConfig UA_ClientConfig_default = {
-    5000, /* .timeout, 5 seconds */
-    10 * 60 * 1000, /* .secureChannelLifeTime, 10 minutes */
-    {UA_Log_Stdout_log, NULL, UA_Log_Stdout_clear}, /* .logger */
-    { /* .localConnectionConfig */
-        0, /* .protocolVersion */
-        65535, /* .sendBufferSize, 64k per chunk */
-        65535, /* .recvBufferSize, 64k per chunk */
-        0, /* .maxMessageSize, 0 -> unlimited */
-        0 /* .maxChunkCount, 0 -> unlimited */
-    },
-    UA_ClientConnectionTCP, /* .connectionFunc (for sync connection) */
-    UA_ClientConnectionTCP_init, /* .initConnectionFunc (for async client) */
-    UA_ClientConnectionTCP_poll_callback, /* .pollConnectionFunc (for async connection) */
-
-    NULL, /* .customDataTypes */
-
-    NULL, /* .stateCallback */
-    0,    /* .connectivityCheckInterval */
-
-    1200000, /* requestedSessionTimeout */
-
-    NULL, /* .inactivityCallback */
-    NULL, /* .clientContext */
+UA_StatusCode
+UA_ClientConfig_setDefault(UA_ClientConfig *config) {
+    config->timeout = 5000;
+    config->secureChannelLifeTime = 10 * 60 * 1000; /* 10 minutes */
+
+    config->logger.log = UA_Log_Stdout_log;
+    config->logger.context = NULL;
+    config->logger.clear = UA_Log_Stdout_clear;
+
+    config->localConnectionConfig.protocolVersion = 0;
+    config->localConnectionConfig.sendBufferSize = 65535;
+    config->localConnectionConfig.recvBufferSize = 65535;
+    config->localConnectionConfig.maxMessageSize = 0; /* 0 -> unlimited */
+    config->localConnectionConfig.maxChunkCount = 0; /* 0 -> unlimited */
+
+    /* Certificate Verification that accepts every certificate. Can be
+     * overwritten when the policy is specialized. */
+    //UA_CertificateVerification_AcceptAll(&config->certificateVerification);
+
+    /* if(config->securityPoliciesSize > 0) { */
+    /*     UA_LOG_ERROR(&config->logger, UA_LOGCATEGORY_NETWORK, */
+    /*                  "Could not initialize a config that already has SecurityPolicies"); */
+    /*     return UA_STATUSCODE_BADINTERNALERROR; */
+    /* } */
+
+    /* config->securityPolicies = (UA_SecurityPolicy*)malloc(sizeof(UA_SecurityPolicy)); */
+    /* if(!config->securityPolicies) */
+    /*     return UA_STATUSCODE_BADOUTOFMEMORY; */
+    /* UA_StatusCode retval = UA_SecurityPolicy_None(config->securityPolicies, NULL, */
+    /*                                               UA_BYTESTRING_NULL, &config->logger); */
+    /* if(retval != UA_STATUSCODE_GOOD) { */
+    /*     free(config->securityPolicies); */
+    /*     config->securityPolicies = NULL; */
+    /*     return retval; */
+    /* } */
+    /* config->securityPoliciesSize = 1; */
+
+    config->connectionFunc = UA_ClientConnectionTCP;
+    config->initConnectionFunc = UA_ClientConnectionTCP_init; /* for async client */
+    config->pollConnectionFunc = UA_ClientConnectionTCP_poll_callback; /* for async connection */
+
+    config->customDataTypes = NULL;
+    config->stateCallback = NULL;
+    config->connectivityCheckInterval = 0;
+
+    config->requestedSessionTimeout = 1200000; /* requestedSessionTimeout */
+
+    config->inactivityCallback = NULL;
+    config->clientContext = NULL;
 
 #ifdef UA_ENABLE_SUBSCRIPTIONS
-    10,  /* .outStandingPublishRequests */
-    NULL /* .subscriptionInactivityCallback */
+    config->outStandingPublishRequests = 10;
+    config->subscriptionInactivityCallback = NULL;
 #endif
-};
+
+    return UA_STATUSCODE_GOOD;
+}

+ 2 - 1
plugins/ua_config_default.h

@@ -112,7 +112,8 @@ UA_ServerConfig_delete(UA_ServerConfig *config);
 /* Default Client Config */
 /*************************/
 
-extern const UA_EXPORT UA_ClientConfig UA_ClientConfig_default;
+UA_StatusCode UA_EXPORT
+UA_ClientConfig_setDefault(UA_ClientConfig *config);
 
 _UA_END_DECLS
 

+ 5 - 118
src/client/ua_client.c

@@ -32,10 +32,8 @@
 /********************/
 
 static void
-UA_Client_init(UA_Client* client, UA_ClientConfig config) {
+UA_Client_init(UA_Client* client) {
     memset(client, 0, sizeof(UA_Client));
-    /* TODO: Select policy according to the endpoint */
-    client->config = config;
     UA_SecurityPolicy_None(&client->securityPolicy, NULL, UA_BYTESTRING_NULL,
                            &client->config.logger);
     UA_SecureChannel_init(&client->channel);
@@ -49,127 +47,16 @@ UA_Client_init(UA_Client* client, UA_ClientConfig config) {
 }
 
 UA_Client *
-UA_Client_new(UA_ClientConfig config) {
+UA_Client_new() {
     UA_Client *client = (UA_Client*)UA_malloc(sizeof(UA_Client));
     if(!client)
         return NULL;
-    UA_Client_init(client, config);
+    UA_Client_init(client);
     return client;
 }
 
-#ifdef UA_ENABLE_ENCRYPTION
-/* Initializes a secure client with the required configuration, certificate
- * privatekey, trustlist and revocation list.
- *
- * @param  client                   client to store configuration
- * @param  config                   new secure configuration for client
- * @param  certificate              client certificate
- * @param  privateKey               client's private key
- * @param  remoteCertificate        server certificate form the endpoints
- * @param  trustList                list of trustable certificate
- * @param  trustListSize            count of trustList
- * @param  revocationList           list of revoked digital certificate
- * @param  revocationListSize       count of revocationList
- * @param  securityPolicyFunction   securityPolicy function
- * @return Returns a client configuration for secure channel */
-static UA_StatusCode
-UA_Client_secure_init(UA_Client* client, UA_ClientConfig config,
-                      const UA_ByteString certificate,
-                      const UA_ByteString privateKey,
-                      const UA_ByteString *remoteCertificate,
-                      const UA_ByteString *trustList, size_t trustListSize,
-                      const UA_ByteString *revocationList,
-                      size_t revocationListSize,
-                      UA_SecurityPolicy_Func securityPolicyFunction) {
-    if(client == NULL || remoteCertificate == NULL)
-        return STATUS_CODE_BAD_POINTER;
-
-    memset(client, 0, sizeof(UA_Client));
-    client->config = config;
-
-    /* Allocate memory for certificate verification */
-    client->securityPolicy.certificateVerification =
-                           (UA_CertificateVerification *)
-                            UA_malloc(sizeof(UA_CertificateVerification));
-
-    UA_StatusCode retval =
-    UA_CertificateVerification_Trustlist(client->securityPolicy.certificateVerification,
-                                         trustList, trustListSize,
-                                         revocationList, revocationListSize);
-
-    if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
-                     "Trust list parsing failed with error %s", UA_StatusCode_name(retval));
-        return retval;
-    }
-
-    /* Initiate client security policy */
-    retval = (*securityPolicyFunction)(&client->securityPolicy,
-                                       client->securityPolicy.certificateVerification,
-                                       certificate, privateKey, &client->config.logger);
-    if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(client->channel.securityPolicy->logger, UA_LOGCATEGORY_CLIENT,
-                     "Failed to setup the SecurityPolicy with error %s", UA_StatusCode_name(retval));
-        return retval;
-    }
-
-    if(client->config.stateCallback)
-        client->config.stateCallback(client, client->state);
-
-    /* Catch error during async connection */
-    client->connectStatus = UA_STATUSCODE_GOOD;
-
-    UA_Timer_init(&client->timer);
-    UA_WorkQueue_init(&client->workQueue);
-
-    /* Initialize the SecureChannel */
-    UA_SecureChannel_init(&client->channel);
-    client->channel.securityMode = UA_MESSAGESECURITYMODE_SIGNANDENCRYPT;
-    retval = UA_SecureChannel_setSecurityPolicy(&client->channel, &client->securityPolicy,
-                                                remoteCertificate);
-    return retval;
-}
-
-/* Creates a new secure client.
- *
- * @param  config                   new secure configuration for client
- * @param  certificate              client certificate
- * @param  privateKey               client's private key
- * @param  remoteCertificate        server certificate form the endpoints
- * @param  trustList                list of trustable certificate
- * @param  trustListSize            count of trustList
- * @param  revocationList           list of revoked digital certificate
- * @param  revocationListSize       count of revocationList
- * @param  securityPolicyFunction   securityPolicy function
- * @return Returns a client with secure configuration */
-UA_Client *
-UA_Client_secure_new(UA_ClientConfig config, UA_ByteString certificate,
-                     UA_ByteString privateKey, const UA_ByteString *remoteCertificate,
-                     const UA_ByteString *trustList, size_t trustListSize,
-                     const UA_ByteString *revocationList, size_t revocationListSize,
-                     UA_SecurityPolicy_Func securityPolicyFunction) {
-    if(remoteCertificate == NULL)
-        return NULL;
-
-    UA_Client *client = (UA_Client *)UA_malloc(sizeof(UA_Client));
-    if(!client)
-        return NULL;
-
-    UA_StatusCode retval = UA_Client_secure_init(client, config, certificate, privateKey,
-                                                 remoteCertificate, trustList, trustListSize,
-                                                 revocationList, revocationListSize,
-                                                 securityPolicyFunction);
-    if(retval != UA_STATUSCODE_GOOD) {
-        UA_free(client);
-        return NULL;
-    }
-
-    return client;
-}
-#endif
-
 static void
-UA_Client_deleteMembers(UA_Client* client) {
+UA_Client_deleteMembers(UA_Client *client) {
     UA_Client_disconnect(client);
     client->securityPolicy.deleteMembers(&client->securityPolicy);
     /* Commented as UA_SecureChannel_deleteMembers already done
@@ -205,7 +92,7 @@ UA_Client_deleteMembers(UA_Client* client) {
 void
 UA_Client_reset(UA_Client* client) {
     UA_Client_deleteMembers(client);
-    UA_Client_init(client, client->config);
+    UA_Client_init(client);
 }
 
 void

+ 30 - 23
tests/client/check_client.c

@@ -74,7 +74,8 @@ static void teardown(void) {
 }
 
 START_TEST(Client_connect) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
 
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
@@ -85,7 +86,8 @@ START_TEST(Client_connect) {
 END_TEST
 
 START_TEST(Client_connect_username) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect_username(client, "opc.tcp://localhost:4840", "user1", "password");
 
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
@@ -96,7 +98,8 @@ START_TEST(Client_connect_username) {
 END_TEST
 
 START_TEST(Client_endpoints) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
 
     UA_EndpointDescription* endpointArray = NULL;
     size_t endpointArraySize = 0;
@@ -112,14 +115,15 @@ START_TEST(Client_endpoints) {
 END_TEST
 
 START_TEST(Client_endpoints_empty) {
-        /* Issue a getEndpoints call with empty endpointUrl.
-         * Using UA_Client_getEndpoints automatically passes the client->endpointUrl as requested endpointUrl.
-         * The spec says:
-         * The Server should return a suitable default URL if it does not recognize the HostName in the URL.
-         *
-         * See https://github.com/open62541/open62541/issues/775
-         */
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    /* Issue a getEndpoints call with empty endpointUrl.
+     * Using UA_Client_getEndpoints automatically passes the client->endpointUrl as requested endpointUrl.
+     * The spec says:
+     * The Server should return a suitable default URL if it does not recognize the HostName in the URL.
+     *
+     * See https://github.com/open62541/open62541/issues/775
+     */
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
 
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
@@ -145,7 +149,8 @@ START_TEST(Client_endpoints_empty) {
 END_TEST
 
 START_TEST(Client_read) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
@@ -162,12 +167,14 @@ START_TEST(Client_read) {
 END_TEST
 
 START_TEST(Client_renewSecureChannel) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
     /* Forward the time */
-    UA_fakeSleep((UA_UInt32)((UA_Double)UA_ClientConfig_default.secureChannelLifeTime * 0.8));
+    UA_ClientConfig *cc = UA_Client_getConfig(client);
+    UA_fakeSleep((UA_UInt32)((UA_Double)cc->secureChannelLifeTime * 0.8));
 
     /* Now read */
     UA_Variant val;
@@ -182,14 +189,14 @@ START_TEST(Client_renewSecureChannel) {
 } END_TEST
 
 START_TEST(Client_renewSecureChannelWithActiveSubscription) {
-    UA_ClientConfig uaClientConfig = UA_ClientConfig_default;
-    uaClientConfig.secureChannelLifeTime = 10000;
-    UA_Client *client = UA_Client_new(uaClientConfig);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+    UA_ClientConfig *cc = UA_Client_getConfig(client);
+    cc->secureChannelLifeTime = 10000;
+
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
-
-
     UA_CreateSubscriptionRequest request = UA_CreateSubscriptionRequest_default();
     request.requestedLifetimeCount = 1000;
     UA_CreateSubscriptionResponse response = UA_Client_Subscriptions_create(client, request,
@@ -208,8 +215,8 @@ START_TEST(Client_renewSecureChannelWithActiveSubscription) {
 } END_TEST
 
 START_TEST(Client_reconnect) {
-    UA_ClientConfig clientConfig = UA_ClientConfig_default;
-    UA_Client *client = UA_Client_new(clientConfig);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
@@ -239,8 +246,8 @@ START_TEST(Client_reconnect) {
 END_TEST
 
 START_TEST(Client_delete_without_connect) {
-    UA_ClientConfig clientConfig = UA_ClientConfig_default;
-    UA_Client *client = UA_Client_new(clientConfig);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     ck_assert_msg(client != NULL);
     UA_Client_delete(client);
 }

+ 27 - 32
tests/client/check_client_async.c

@@ -65,15 +65,13 @@ static void asyncReadValueAtttributeCallback(UA_Client *client, void *userdata,
     UA_fakeSleep(10);
 }
 
-START_TEST(Client_highlevel_async_readValue)
-    {
-        UA_ClientConfig clientConfig = UA_ClientConfig_default;
-        clientConfig.outStandingPublishRequests = 0;
+START_TEST(Client_highlevel_async_readValue) {
+        UA_Client *client = UA_Client_new();
+        UA_ClientConfig *clientConfig = UA_Client_getConfig(client);
+        UA_ClientConfig_setDefault(clientConfig);
+        clientConfig->outStandingPublishRequests = 0;
 
-        UA_Client *client = UA_Client_new(clientConfig);
-
-        UA_StatusCode retval = UA_Client_connect(client,
-                "opc.tcp://localhost:4840");
+        UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
         ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
         UA_Client_recv = client->connection.recv;
@@ -105,11 +103,12 @@ START_TEST(Client_highlevel_async_readValue)
 
 
 
-START_TEST(Client_read_async)
-    {
-        UA_Client *client = UA_Client_new(UA_ClientConfig_default);
-        UA_StatusCode retval = UA_Client_connect(client,
-                "opc.tcp://localhost:4840");
+START_TEST(Client_read_async) {
+        UA_Client *client = UA_Client_new();
+        UA_ClientConfig *clientConfig = UA_Client_getConfig(client);
+        UA_ClientConfig_setDefault(clientConfig);
+
+        UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
         ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
         UA_UInt16 asyncCounter = 0;
@@ -144,15 +143,13 @@ START_TEST(Client_read_async)
         UA_Client_delete(client);
     }END_TEST
 
-START_TEST(Client_read_async_timed)
-    {
-        UA_ClientConfig clientConfig = UA_ClientConfig_default;
-        clientConfig.outStandingPublishRequests = 0;
+START_TEST(Client_read_async_timed) {
+        UA_Client *client = UA_Client_new();
+        UA_ClientConfig *clientConfig = UA_Client_getConfig(client);
+        UA_ClientConfig_setDefault(clientConfig);
+        clientConfig->outStandingPublishRequests = 0;
 
-        UA_Client *client = UA_Client_new(clientConfig);
-
-        UA_StatusCode retval = UA_Client_connect(client,
-                "opc.tcp://localhost:4840");
+        UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
         ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
         UA_Client_recv = client->connection.recv;
@@ -205,17 +202,15 @@ static void inactivityCallback(UA_Client *client) {
     inactivityCallbackTriggered = true;
 }
 
-START_TEST(Client_connectivity_check)
-    {
-        UA_ClientConfig clientConfig = UA_ClientConfig_default;
-        clientConfig.outStandingPublishRequests = 0;
-        clientConfig.inactivityCallback = inactivityCallback;
-        clientConfig.connectivityCheckInterval = 1000;
-
-        UA_Client *client = UA_Client_new(clientConfig);
+START_TEST(Client_connectivity_check) {
+        UA_Client *client = UA_Client_new();
+        UA_ClientConfig *clientConfig = UA_Client_getConfig(client);
+        UA_ClientConfig_setDefault(clientConfig);
+        clientConfig->outStandingPublishRequests = 0;
+        clientConfig->inactivityCallback = inactivityCallback;
+        clientConfig->connectivityCheckInterval = 1000;
 
-        UA_StatusCode retval = UA_Client_connect(client,
-                "opc.tcp://localhost:4840");
+        UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
         ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
         UA_Client_recv = client->connection.recv;
@@ -231,7 +226,7 @@ START_TEST(Client_connectivity_check)
         UA_Client_recvTesting_result = UA_STATUSCODE_GOODNONCRITICALTIMEOUT;
 
         retval = UA_Client_run_iterate(client,
-                (UA_UInt16) (1000 + 1 + clientConfig.timeout));
+                (UA_UInt16) (1000 + 1 + clientConfig->timeout));
         ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
         ck_assert_uint_eq(inactivityCallbackTriggered, true);
 

+ 10 - 9
tests/client/check_client_async_connect.c

@@ -63,10 +63,10 @@ asyncBrowseCallback(UA_Client *Client, void *userdata,
 
 START_TEST(Client_connect_async){
     UA_StatusCode retval;
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_Boolean connected = false;
-    UA_Client_connect_async(client, "opc.tcp://localhost:4840", onConnect,
-                            &connected);
+    UA_Client_connect_async(client, "opc.tcp://localhost:4840", onConnect, &connected);
     /*Windows needs time to response*/
     UA_sleep_ms(100);
     UA_UInt32 reqId = 0;
@@ -105,11 +105,12 @@ START_TEST(Client_connect_async){
 END_TEST
 
 START_TEST(Client_no_connection) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
 
     UA_Boolean connected = false;
-    UA_StatusCode retval = UA_Client_connect_async(client, "opc.tcp://localhost:4840", onConnect,
-            &connected);
+    UA_StatusCode retval =
+        UA_Client_connect_async(client, "opc.tcp://localhost:4840", onConnect, &connected);
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
     UA_Client_recv = client->connection.recv;
@@ -124,10 +125,10 @@ START_TEST(Client_no_connection) {
 END_TEST
 
 START_TEST(Client_without_run_iterate) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_Boolean connected = false;
-    UA_Client_connect_async(client, "opc.tcp://localhost:4840", onConnect,
-                            &connected);
+    UA_Client_connect_async(client, "opc.tcp://localhost:4840", onConnect, &connected);
     UA_Client_delete(client);
 }
 END_TEST

+ 2 - 1
tests/client/check_client_highlevel.c

@@ -37,7 +37,8 @@ static void setup(void) {
     UA_Server_run_startup(server);
     THREAD_CREATE(server_thread, serverloop);
 
-    client = UA_Client_new(UA_ClientConfig_default);
+    client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 }

+ 2 - 1
tests/client/check_client_historical_data.c

@@ -115,7 +115,8 @@ setup(void)
 
     ck_assert(fillHistoricalDataBackend(setting.historizingBackend));
 #endif
-    client = UA_Client_new(UA_ClientConfig_default);
+    client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_str_eq(UA_StatusCode_name(retval), UA_StatusCode_name(UA_STATUSCODE_GOOD));
 

+ 23 - 9
tests/client/check_client_securechannel.c

@@ -43,11 +43,14 @@ static void teardown(void) {
 }
 
 START_TEST(SecureChannel_timeout_max) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
-    UA_fakeSleep(UA_ClientConfig_default.secureChannelLifeTime);
+    UA_ClientConfig *cconfig = UA_Client_getConfig(client);
+    UA_fakeSleep(cconfig->secureChannelLifeTime);
 
     UA_Variant val;
     UA_NodeId nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_STATE);
@@ -63,11 +66,14 @@ END_TEST
 
 /* Send the next message after the securechannel timed out */
 START_TEST(SecureChannel_timeout_fail) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
-    UA_fakeSleep(UA_ClientConfig_default.secureChannelLifeTime+1);
+    UA_ClientConfig *cconfig = UA_Client_getConfig(client);
+    UA_fakeSleep(cconfig->secureChannelLifeTime + 1);
     UA_realSleep(50 + 1); // UA_MAXTIMEOUT+1 wait to be sure UA_Server_run_iterate can be completely executed
 
     UA_Variant val;
@@ -85,7 +91,9 @@ END_TEST
 
 /* Send an async message and receive the response when the securechannel timed out */
 START_TEST(SecureChannel_networkfail) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
@@ -99,9 +107,10 @@ START_TEST(SecureChannel_networkfail) {
     rq.nodesToReadSize = 1;
 
     /* Forward the clock after recv in the client */
+    UA_ClientConfig *cconfig = UA_Client_getConfig(client);
     UA_Client_recv = client->connection.recv;
     client->connection.recv = UA_Client_recvTesting;
-    UA_Client_recvSleepDuration = UA_ClientConfig_default.secureChannelLifeTime+1;
+    UA_Client_recvSleepDuration = cconfig->secureChannelLifeTime + 1;
 
     UA_Variant val;
     UA_Variant_init(&val);
@@ -115,7 +124,9 @@ START_TEST(SecureChannel_networkfail) {
 END_TEST
 
 START_TEST(SecureChannel_reconnect) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
     
@@ -124,7 +135,8 @@ START_TEST(SecureChannel_reconnect) {
     retval = UA_Client_disconnect(client);
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
-    UA_fakeSleep(UA_ClientConfig_default.secureChannelLifeTime+1);
+    UA_ClientConfig *cconfig = UA_Client_getConfig(client);
+    UA_fakeSleep(cconfig->secureChannelLifeTime + 1);
     UA_realSleep(50 + 1);
 
     retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
@@ -135,7 +147,9 @@ START_TEST(SecureChannel_reconnect) {
 END_TEST
 
 START_TEST(SecureChannel_cableunplugged) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 

+ 23 - 12
tests/client/check_client_subscriptions.c

@@ -60,7 +60,9 @@ dataChangeHandler(UA_Client *client, UA_UInt32 subId, void *subContext,
 }
 
 START_TEST(Client_subscription) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
@@ -104,7 +106,8 @@ START_TEST(Client_subscription) {
 END_TEST
 
 START_TEST(Client_subscription_createDataChanges) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
@@ -204,7 +207,8 @@ START_TEST(Client_subscription_createDataChanges) {
 END_TEST
 
 START_TEST(Client_subscription_keepAlive) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
@@ -267,7 +271,9 @@ START_TEST(Client_subscription_keepAlive) {
 END_TEST
 
 START_TEST(Client_subscription_connectionClose) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
@@ -306,7 +312,8 @@ START_TEST(Client_subscription_connectionClose) {
 END_TEST
 
 START_TEST(Client_subscription_without_notification) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
@@ -394,16 +401,18 @@ subscriptionInactivityCallback (UA_Client *client, UA_UInt32 subId, void *subCon
 }
 
 START_TEST(Client_subscription_async_sub) {
-    UA_ClientConfig clientConfig = UA_ClientConfig_default;
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+
     /* Set stateCallback */
-    clientConfig.stateCallback = stateCallback;
-    clientConfig.subscriptionInactivityCallback = subscriptionInactivityCallback;
+    UA_ClientConfig *cc = UA_Client_getConfig(client);
+    cc->stateCallback = stateCallback;
+    cc->subscriptionInactivityCallback = subscriptionInactivityCallback;
     inactivityCallbackCalled = false;
 
     /* Activate background publish request */
-    clientConfig.outStandingPublishRequests = 10;
+    cc->outStandingPublishRequests = 10;
 
-    UA_Client *client = UA_Client_new(clientConfig);
     ck_assert_uint_eq(callbackClientState, UA_CLIENTSTATE_DISCONNECTED);
 
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
@@ -454,7 +463,7 @@ START_TEST(Client_subscription_async_sub) {
     /* Simulate network cable unplugged (no response from server) */
     ck_assert_uint_eq(inactivityCallbackCalled, false);
     UA_Client_recvTesting_result = UA_STATUSCODE_GOODNONCRITICALTIMEOUT;
-    UA_Client_run_iterate(client, (UA_UInt16)clientConfig.timeout);
+    UA_Client_run_iterate(client, (UA_UInt16)cc->timeout);
     ck_assert_uint_eq(inactivityCallbackCalled, true);
     ck_assert_uint_eq(callbackClientState, UA_CLIENTSTATE_SESSION);
 
@@ -464,7 +473,9 @@ END_TEST
 
 #ifdef UA_ENABLE_METHODCALLS
 START_TEST(Client_methodcall) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 

+ 9 - 9
tests/encryption/check_encryption_basic128rsa15.c

@@ -86,8 +86,8 @@ START_TEST(encryption_connect) {
     size_t endpointArraySize = 0;
     UA_ByteString *trustList = NULL;
     size_t trustListSize = 0;
-    UA_ByteString *revocationList = NULL;
-    size_t revocationListSize = 0;
+    /* UA_ByteString *revocationList = NULL; */
+    /* size_t revocationListSize = 0; */
     UA_ByteString *remoteCertificate = NULL;
 
     /* Load certificate and private key */
@@ -104,7 +104,8 @@ START_TEST(encryption_connect) {
     /* The Get endpoint (discovery service) is done with
      * security mode as none to see the server's capability
      * and certificate */
-    client = UA_Client_new(UA_ClientConfig_default);
+    client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     ck_assert_msg(client != NULL);
     remoteCertificate = UA_ByteString_new();
     UA_StatusCode retval = UA_Client_getEndpoints(client, "opc.tcp://localhost:4840",
@@ -141,12 +142,11 @@ START_TEST(encryption_connect) {
     UA_Client_delete(client);
 
     /* Secure client initialization */
-    client = UA_Client_secure_new(UA_ClientConfig_default,
-                                  certificate, privateKey,
-                                  remoteCertificate,
-                                  trustList, trustListSize,
-                                  revocationList, revocationListSize,
-                                  UA_SecurityPolicy_Basic128Rsa15);
+    client = UA_Client_new();
+    /* UA_ClientConfig *cc = UA_Client_getConfig(client); */
+    /* UA_ClientConfig_setDefaultEncryption(cc, certificate, privateKey, */
+    /*                                      trustList, trustListSize, */
+    /*                                      revocationList, revocationListSize); */
     ck_assert_msg(client != NULL);
 
     for(size_t deleteCount = 0; deleteCount < trustListSize; deleteCount++) {

+ 9 - 9
tests/encryption/check_encryption_basic256sha256.c

@@ -86,8 +86,8 @@ START_TEST(encryption_connect) {
     size_t endpointArraySize = 0;
     UA_ByteString *trustList = NULL;
     size_t trustListSize = 0;
-    UA_ByteString *revocationList = NULL;
-    size_t revocationListSize = 0;
+    /* UA_ByteString *revocationList = NULL; */
+    /* size_t revocationListSize = 0; */
     UA_ByteString *remoteCertificate = NULL;
 
     /* Load certificate and private key */
@@ -104,7 +104,8 @@ START_TEST(encryption_connect) {
     /* The Get endpoint (discovery service) is done with
      * security mode as none to see the server's capability
      * and certificate */
-    client = UA_Client_new(UA_ClientConfig_default);
+    client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     ck_assert_msg(client != NULL);
     remoteCertificate = UA_ByteString_new();
     UA_StatusCode retval = UA_Client_getEndpoints(client, "opc.tcp://localhost:4840",
@@ -141,12 +142,11 @@ START_TEST(encryption_connect) {
     UA_Client_delete(client);
 
     /* Secure client initialization */
-    client = UA_Client_secure_new(UA_ClientConfig_default,
-                                  certificate, privateKey,
-                                  remoteCertificate,
-                                  trustList, trustListSize,
-                                  revocationList, revocationListSize,
-                                  UA_SecurityPolicy_Basic256Sha256);
+    client = UA_Client_new();
+    /* UA_ClientConfig *cc = UA_Client_getConfig(client); */
+    /* UA_ClientConfig_setDefaultEncryption(cc, certificate, privateKey, */
+    /*                                      trustList, trustListSize, */
+    /*                                      revocationList, revocationListSize); */
     ck_assert_msg(client != NULL);
 
     for(size_t deleteCount = 0; deleteCount < trustListSize; deleteCount++) {

+ 31 - 28
tests/server/check_accesscontrol.c

@@ -41,48 +41,51 @@ static void teardown(void) {
 }
 
 START_TEST(Client_anonymous) {
-        UA_Client *client = UA_Client_new(UA_ClientConfig_default);
-        UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+    UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
 
-        ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
+    ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
-        UA_Client_disconnect(client);
-        UA_Client_delete(client);
-    }
-END_TEST
+    UA_Client_disconnect(client);
+    UA_Client_delete(client);
+} END_TEST
 
 START_TEST(Client_user_pass_ok) {
-        UA_Client *client = UA_Client_new(UA_ClientConfig_default);
-        UA_StatusCode retval = UA_Client_connect_username(client, "opc.tcp://localhost:4840", "user1", "password");
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+    UA_StatusCode retval =
+        UA_Client_connect_username(client, "opc.tcp://localhost:4840", "user1", "password");
 
-        ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
+    ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
-        UA_Client_disconnect(client);
-        UA_Client_delete(client);
-    }
-END_TEST
+    UA_Client_disconnect(client);
+    UA_Client_delete(client);
+} END_TEST
 
 START_TEST(Client_user_fail) {
-        UA_Client *client = UA_Client_new(UA_ClientConfig_default);
-        UA_StatusCode retval = UA_Client_connect_username(client, "opc.tcp://localhost:4840", "user0", "password");
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+    UA_StatusCode retval =
+        UA_Client_connect_username(client, "opc.tcp://localhost:4840", "user0", "password");
 
-        ck_assert_uint_eq(retval, UA_STATUSCODE_BADUSERACCESSDENIED);
+    ck_assert_uint_eq(retval, UA_STATUSCODE_BADUSERACCESSDENIED);
 
-        UA_Client_disconnect(client);
-        UA_Client_delete(client);
-    }
-END_TEST
+    UA_Client_disconnect(client);
+    UA_Client_delete(client);
+} END_TEST
 
 START_TEST(Client_pass_fail) {
-        UA_Client *client = UA_Client_new(UA_ClientConfig_default);
-        UA_StatusCode retval = UA_Client_connect_username(client, "opc.tcp://localhost:4840", "user1", "secret");
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
+    UA_StatusCode retval =
+        UA_Client_connect_username(client, "opc.tcp://localhost:4840", "user1", "secret");
 
-        ck_assert_uint_eq(retval, UA_STATUSCODE_BADUSERACCESSDENIED);
+    ck_assert_uint_eq(retval, UA_STATUSCODE_BADUSERACCESSDENIED);
 
-        UA_Client_disconnect(client);
-        UA_Client_delete(client);
-    }
-END_TEST
+    UA_Client_disconnect(client);
+    UA_Client_delete(client);
+} END_TEST
 
 
 static Suite* testSuite_Client(void) {

+ 16 - 8
tests/server/check_discovery.c

@@ -112,8 +112,9 @@ static void teardown_register(void) {
 }
 
 START_TEST(Server_register) {
-    UA_Client *clientRegister = UA_Client_new(UA_ClientConfig_default);
-    ck_assert(clientRegister != NULL);
+    UA_Client *clientRegister = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(clientRegister));
+
     UA_StatusCode retval = UA_Client_connect_noSession(clientRegister, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
     retval = UA_Server_register_discovery(server_register, clientRegister , NULL);
@@ -124,8 +125,9 @@ START_TEST(Server_register) {
 END_TEST
 
 START_TEST(Server_unregister) {
-    UA_Client *clientRegister = UA_Client_new(UA_ClientConfig_default);
-    ck_assert(clientRegister != NULL);
+    UA_Client *clientRegister = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(clientRegister));
+
     UA_StatusCode retval = UA_Client_connect_noSession(clientRegister, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
     retval = UA_Server_unregister_discovery(server_register, clientRegister);
@@ -153,8 +155,10 @@ START_TEST(Server_register_semaphore) {
     ck_assert_ptr_ne(fp, NULL);
     fclose(fp);
 #endif
-    UA_Client *clientRegister = UA_Client_new(UA_ClientConfig_default);
-    ck_assert(clientRegister != NULL);
+
+    UA_Client *clientRegister = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(clientRegister));
+
     UA_StatusCode retval = UA_Client_connect_noSession(clientRegister, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
     retval = UA_Server_register_discovery(server_register, clientRegister, SEMAPHORE_PATH);
@@ -172,7 +176,10 @@ END_TEST
 
 START_TEST(Server_register_periodic) {
     ck_assert(clientRegisterRepeated == NULL);
-    clientRegisterRepeated = UA_Client_new(UA_ClientConfig_default);
+
+    clientRegisterRepeated = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(clientRegisterRepeated));
+
     ck_assert(clientRegisterRepeated != NULL);
     // periodic register every minute, first register immediately
     UA_StatusCode retval = UA_Server_addPeriodicServerRegisterCallback(server_register, clientRegisterRepeated, "opc.tcp://localhost:4840",
@@ -200,7 +207,8 @@ FindAndCheck(const UA_String expectedUris[], size_t expectedUrisSize,
              const UA_String expectedNames[],
              const char *filterUri,
              const char *filterLocale) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
 
     UA_ApplicationDescription* applicationDescriptionArray = NULL;
     size_t applicationDescriptionArraySize = 0;

+ 2 - 1
tests/server/check_monitoreditem_filter.c

@@ -85,7 +85,8 @@ static void setup(void) {
                                                 attr, NULL, NULL)
                       , UA_STATUSCODE_GOOD);
 
-    client = UA_Client_new(UA_ClientConfig_default);
+    client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 

+ 2 - 1
tests/server/check_server_historical_data.c

@@ -122,7 +122,8 @@ setup(void)
         exit(1);
     }
 
-    client = UA_Client_new(UA_ClientConfig_default);
+    client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
     retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
     if (retval != UA_STATUSCODE_GOOD)
     {

+ 2 - 1
tests/server/check_services_view.c

@@ -126,7 +126,8 @@ START_TEST(Service_Browse_WithBrowseName) {
 END_TEST
 
 START_TEST(Service_TranslateBrowsePathsToNodeIds) {
-    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
+    UA_Client *client = UA_Client_new();
+    UA_ClientConfig_setDefault(UA_Client_getConfig(client));
 
     UA_StatusCode retVal = UA_Client_connect(client, "opc.tcp://localhost:4840");
     ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);