|
@@ -398,7 +398,7 @@ UA_Server_removeCallback(UA_Server *server, UA_UInt64 callbackId) {
|
|
UA_UNLOCK(server->serviceMutex);
|
|
UA_UNLOCK(server->serviceMutex);
|
|
}
|
|
}
|
|
|
|
|
|
-UA_StatusCode UA_EXPORT
|
|
|
|
|
|
+UA_StatusCode
|
|
UA_Server_updateCertificate(UA_Server *server,
|
|
UA_Server_updateCertificate(UA_Server *server,
|
|
const UA_ByteString *oldCertificate,
|
|
const UA_ByteString *oldCertificate,
|
|
const UA_ByteString *newCertificate,
|
|
const UA_ByteString *newCertificate,
|
|
@@ -406,16 +406,14 @@ UA_Server_updateCertificate(UA_Server *server,
|
|
UA_Boolean closeSessions,
|
|
UA_Boolean closeSessions,
|
|
UA_Boolean closeSecureChannels) {
|
|
UA_Boolean closeSecureChannels) {
|
|
|
|
|
|
- if (server == NULL || oldCertificate == NULL
|
|
|
|
- || newCertificate == NULL || newPrivateKey == NULL) {
|
|
|
|
|
|
+ if(!server || !oldCertificate || !newCertificate || !newPrivateKey)
|
|
return UA_STATUSCODE_BADINTERNALERROR;
|
|
return UA_STATUSCODE_BADINTERNALERROR;
|
|
- }
|
|
|
|
|
|
|
|
- if (closeSessions) {
|
|
|
|
|
|
+ if(closeSessions) {
|
|
UA_SessionManager *sm = &server->sessionManager;
|
|
UA_SessionManager *sm = &server->sessionManager;
|
|
session_list_entry *current;
|
|
session_list_entry *current;
|
|
LIST_FOREACH(current, &sm->sessions, pointers) {
|
|
LIST_FOREACH(current, &sm->sessions, pointers) {
|
|
- if (UA_ByteString_equal(oldCertificate,
|
|
|
|
|
|
+ if(UA_ByteString_equal(oldCertificate,
|
|
¤t->session.header.channel->securityPolicy->localCertificate)) {
|
|
¤t->session.header.channel->securityPolicy->localCertificate)) {
|
|
UA_LOCK(server->serviceMutex);
|
|
UA_LOCK(server->serviceMutex);
|
|
UA_SessionManager_removeSession(sm, ¤t->session.header.authenticationToken);
|
|
UA_SessionManager_removeSession(sm, ¤t->session.header.authenticationToken);
|
|
@@ -425,7 +423,7 @@ UA_Server_updateCertificate(UA_Server *server,
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if (closeSecureChannels) {
|
|
|
|
|
|
+ if(closeSecureChannels) {
|
|
UA_SecureChannelManager *cm = &server->secureChannelManager;
|
|
UA_SecureChannelManager *cm = &server->secureChannelManager;
|
|
channel_entry *entry;
|
|
channel_entry *entry;
|
|
TAILQ_FOREACH(entry, &cm->channels, pointers) {
|
|
TAILQ_FOREACH(entry, &cm->channels, pointers) {
|
|
@@ -436,9 +434,9 @@ UA_Server_updateCertificate(UA_Server *server,
|
|
}
|
|
}
|
|
|
|
|
|
size_t i = 0;
|
|
size_t i = 0;
|
|
- while (i < server->config.endpointsSize) {
|
|
|
|
|
|
+ while(i < server->config.endpointsSize) {
|
|
UA_EndpointDescription *ed = &server->config.endpoints[i];
|
|
UA_EndpointDescription *ed = &server->config.endpoints[i];
|
|
- if (UA_ByteString_equal(&ed->serverCertificate, oldCertificate)) {
|
|
|
|
|
|
+ if(UA_ByteString_equal(&ed->serverCertificate, oldCertificate)) {
|
|
UA_String_deleteMembers(&ed->serverCertificate);
|
|
UA_String_deleteMembers(&ed->serverCertificate);
|
|
UA_String_copy(newCertificate, &ed->serverCertificate);
|
|
UA_String_copy(newCertificate, &ed->serverCertificate);
|
|
UA_SecurityPolicy *sp = UA_SecurityPolicy_getSecurityPolicyByUri(server, &server->config.endpoints[i].securityPolicyUri);
|
|
UA_SecurityPolicy *sp = UA_SecurityPolicy_getSecurityPolicyByUri(server, &server->config.endpoints[i].securityPolicyUri);
|
|
@@ -555,16 +553,18 @@ UA_Server_run_startup(UA_Server *server) {
|
|
|
|
|
|
/* Update the application description to match the previously added discovery urls.
|
|
/* Update the application description to match the previously added discovery urls.
|
|
* We can only do this after the network layer is started since it inits the discovery url */
|
|
* We can only do this after the network layer is started since it inits the discovery url */
|
|
- if (server->config.applicationDescription.discoveryUrlsSize != 0) {
|
|
|
|
- UA_Array_delete(server->config.applicationDescription.discoveryUrls, server->config.applicationDescription.discoveryUrlsSize, &UA_TYPES[UA_TYPES_STRING]);
|
|
|
|
|
|
+ if(server->config.applicationDescription.discoveryUrlsSize != 0) {
|
|
|
|
+ UA_Array_delete(server->config.applicationDescription.discoveryUrls,
|
|
|
|
+ server->config.applicationDescription.discoveryUrlsSize,
|
|
|
|
+ &UA_TYPES[UA_TYPES_STRING]);
|
|
server->config.applicationDescription.discoveryUrlsSize = 0;
|
|
server->config.applicationDescription.discoveryUrlsSize = 0;
|
|
}
|
|
}
|
|
- server->config.applicationDescription.discoveryUrls = (UA_String *) UA_Array_new(server->config.networkLayersSize, &UA_TYPES[UA_TYPES_STRING]);
|
|
|
|
- if (!server->config.applicationDescription.discoveryUrls) {
|
|
|
|
|
|
+ server->config.applicationDescription.discoveryUrls = (UA_String *)
|
|
|
|
+ UA_Array_new(server->config.networkLayersSize, &UA_TYPES[UA_TYPES_STRING]);
|
|
|
|
+ if(!server->config.applicationDescription.discoveryUrls)
|
|
return UA_STATUSCODE_BADOUTOFMEMORY;
|
|
return UA_STATUSCODE_BADOUTOFMEMORY;
|
|
- }
|
|
|
|
server->config.applicationDescription.discoveryUrlsSize = server->config.networkLayersSize;
|
|
server->config.applicationDescription.discoveryUrlsSize = server->config.networkLayersSize;
|
|
- for (size_t i=0; i< server->config.applicationDescription.discoveryUrlsSize; i++) {
|
|
|
|
|
|
+ for(size_t i = 0; i < server->config.applicationDescription.discoveryUrlsSize; i++) {
|
|
UA_ServerNetworkLayer *nl = &server->config.networkLayers[i];
|
|
UA_ServerNetworkLayer *nl = &server->config.networkLayers[i];
|
|
UA_String_copy(&nl->discoveryUrl, &server->config.applicationDescription.discoveryUrls[i]);
|
|
UA_String_copy(&nl->discoveryUrl, &server->config.applicationDescription.discoveryUrls[i]);
|
|
}
|
|
}
|