mirror of
https://github.com/open62541/open62541.git
synced 2025-06-03 04:00:21 +00:00
server_ctt starts without defined certificate
Before the server would just exist. This fixes #1853.
This commit is contained in:
parent
f16aa923d0
commit
adaa64f3fc
@ -420,55 +420,56 @@ int main(int argc, char **argv) {
|
|||||||
signal(SIGINT, stopHandler); /* catches ctrl-c */
|
signal(SIGINT, stopHandler); /* catches ctrl-c */
|
||||||
signal(SIGTERM, stopHandler);
|
signal(SIGTERM, stopHandler);
|
||||||
|
|
||||||
|
UA_ServerConfig *config;
|
||||||
#ifdef UA_ENABLE_ENCRYPTION
|
#ifdef UA_ENABLE_ENCRYPTION
|
||||||
if(argc < 3) {
|
if(argc < 3) {
|
||||||
UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
|
UA_LOG_WARNING(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
|
||||||
"Missing arguments for encryption support. "
|
"Missing arguments for encryption support. "
|
||||||
"Arguments are <server-certificate.der> "
|
"Arguments are <server-certificate.der> "
|
||||||
"<private-key.der> [<trustlist1.crl>, ...]");
|
"<private-key.der> [<trustlist1.crl>, ...]");
|
||||||
return 1;
|
config = UA_ServerConfig_new_minimal(4840, NULL);
|
||||||
|
} else {
|
||||||
|
/* 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 revocation list currently unsupported */
|
||||||
|
UA_ByteString *revocationList = NULL;
|
||||||
|
size_t revocationListSize = 0;
|
||||||
|
|
||||||
|
config = UA_ServerConfig_new_allSecurityPolicies(4840, &certificate, &privateKey,
|
||||||
|
trustList, trustListSize,
|
||||||
|
revocationList, revocationListSize);
|
||||||
|
UA_ByteString_deleteMembers(&certificate);
|
||||||
|
UA_ByteString_deleteMembers(&privateKey);
|
||||||
|
for(size_t i = 0; i < trustListSize; i++)
|
||||||
|
UA_ByteString_deleteMembers(&trustList[i]);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
/* Load certificate and private key */
|
UA_ByteString certificate = UA_BYTESTRING_NULL;
|
||||||
UA_ByteString certificate = loadFile(argv[1]);
|
if(argc < 2) {
|
||||||
UA_ByteString privateKey = loadFile(argv[2]);
|
UA_LOG_WARNING(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
|
||||||
|
"Missing argument for the server certificate");
|
||||||
/* Load the trustlist */
|
} else {
|
||||||
size_t trustListSize = 0;
|
certificate = loadFile(argv[1]);
|
||||||
if(argc > 3)
|
}
|
||||||
trustListSize = (size_t)argc-3;
|
config = UA_ServerConfig_new_minimal(4840, &certificate);
|
||||||
UA_STACKARRAY(UA_ByteString, trustList, trustListSize);
|
|
||||||
for(size_t i = 0; i < trustListSize; i++)
|
|
||||||
trustList[i] = loadFile(argv[i+3]);
|
|
||||||
|
|
||||||
/* Loading of a revocation list currently unsupported */
|
|
||||||
UA_ByteString *revocationList = NULL;
|
|
||||||
size_t revocationListSize = 0;
|
|
||||||
|
|
||||||
UA_ServerConfig *config =
|
|
||||||
UA_ServerConfig_new_allSecurityPolicies(4840, &certificate, &privateKey,
|
|
||||||
trustList, trustListSize,
|
|
||||||
revocationList, revocationListSize);
|
|
||||||
UA_ByteString_deleteMembers(&certificate);
|
UA_ByteString_deleteMembers(&certificate);
|
||||||
UA_ByteString_deleteMembers(&privateKey);
|
#endif
|
||||||
for(size_t i = 0; i < trustListSize; i++)
|
|
||||||
UA_ByteString_deleteMembers(&trustList[i]);
|
|
||||||
|
|
||||||
if(!config) {
|
if(!config) {
|
||||||
UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
|
UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
|
||||||
"Could not create the server config");
|
"Could not create the server config");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if(argc < 2) {
|
|
||||||
UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
|
|
||||||
"Missing argument for the server certificate");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
UA_ByteString certificate = loadFile(argv[1]);
|
|
||||||
UA_ServerConfig *config = UA_ServerConfig_new_minimal(4840, &certificate);
|
|
||||||
UA_ByteString_deleteMembers(&certificate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Override with a custom access control policy */
|
/* Override with a custom access control policy */
|
||||||
config->accessControl.getUserAccessLevel = getUserAccessLevel_disallowSpecific;
|
config->accessControl.getUserAccessLevel = getUserAccessLevel_disallowSpecific;
|
||||||
|
Loading…
Reference in New Issue
Block a user