Parcourir la source

Client: Fix logging edge case during startup

Julius Pfrommer il y a 5 ans
Parent
commit
29a0e6a492
1 fichiers modifiés avec 4 ajouts et 3 suppressions
  1. 4 3
      src/client/ua_client.c

+ 4 - 3
src/client/ua_client.c

@@ -85,6 +85,8 @@ UA_Client_secure_init(UA_Client* client, UA_ClientConfig config,
         return STATUS_CODE_BAD_POINTER;
 
     memset(client, 0, sizeof(UA_Client));
+    client->config = config;
+
     /* Allocate memory for certificate verification */
     client->securityPolicy.certificateVerification =
                            (UA_CertificateVerification *)
@@ -96,7 +98,7 @@ UA_Client_secure_init(UA_Client* client, UA_ClientConfig config,
                                          revocationList, revocationListSize);
 
     if(retval != UA_STATUSCODE_GOOD) {
-        UA_LOG_ERROR(client->channel.securityPolicy->logger, UA_LOGCATEGORY_SECURECHANNEL,
+        UA_LOG_ERROR(&client->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                      "Trust list parsing failed with error %s", UA_StatusCode_name(retval));
         return retval;
     }
@@ -104,14 +106,13 @@ UA_Client_secure_init(UA_Client* client, UA_ClientConfig config,
     /* Initiate client security policy */
     retval = (*securityPolicyFunction)(&client->securityPolicy,
                                        client->securityPolicy.certificateVerification,
-                                       certificate, privateKey, &config.logger);
+                                       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;
     }
 
-    client->config = config;
     if(client->config.stateCallback)
         client->config.stateCallback(client, client->state);