瀏覽代碼

Check if server_ctt certificate and private key are found

If the files aren't found give the user an error
Ari 6 年之前
父節點
當前提交
00eef714d6
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      examples/server_ctt.c

+ 10 - 0
examples/server_ctt.c

@@ -426,7 +426,17 @@ int main(int argc, char **argv) {
     } else {
         /* Load certificate and private key */
         UA_ByteString certificate = loadFile(argv[1]);
+        if(certificate.length == 0) {
+            UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                           "Unable to load file %s.", argv[1]);
+            return 1;
+        }
         UA_ByteString privateKey = loadFile(argv[2]);
+        if(privateKey.length == 0) {
+            UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
+                           "Unable to load file %s.", argv[2]);
+            return 1;
+        }
 
         /* Load the trustlist */
         size_t trustListSize = 0;