微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Eclipse Milo 证书

如何解决Eclipse Milo 证书

我是 Milo 的新手,我遇到了一个问题: 我必须使用 X509 证书在 milo 客户端和服务器(都在本地主机上)之间建立连接。 为此,我使用了 https://github.com/eclipse/milo/tree/master/milo-examples 的 KeyStoreLoader 类,几乎没有改动它们。 服务器和客户端都启动没有问题,但客户端没有连接,产生:

#include<iostream>
#include<fstream>
#include<string_view>
#include<string>
#include<sstream>
#include<exception>

int main(int argc,char** argv) {
    std::cout << "starting mVote...\n";

    //parse command line argumentand get the filename
    std::string filename = argv[2]; // NO CHECKS!
    std::cout << filename <<'\n';

    //from here,I'm opening the file and read it by lines
    {
        std::ifstream ifs(filename);
        if (!ifs) {
            throw std::invalid_argument("file not exists");
        }
        std::string line;
        while (std::getline(ifs,line)) {
            std::cout << line << '\n';
        }
    }

    bool run_flag = true;
    while (run_flag) {
        std::cout << "what do you want?\n";
        std::string userInput;
        std::getline(std::cin,userInput);
        if (userInput == "exit") {
            std::cout << "bye!\n";
            return 0;
        }
        std::stringstream userInputSs(userInput);
        std::string operation;
        while(userInputSs >> operation){
            std::cout << "operation: " << operation << '\n';
        }
    }
}

在 ClientExample 接口中,我有这个 getIdentityProvider() 方法

13:07:34.671 [main] INFO  milo_test.client.browseExample - security temp dir: /tmp/security
13:07:34.671 [main] INFO  milo_test.client.KeyStoreLoader - Loading KeyStore at /tmp/security/example-client.pem
13:07:35.417 [main] ERROR milo_test.client.ClientExampleRunner - Error running client example: UaServiceFaultException: status=Bad_SecurityChecksFailed,message=An error occurred verifying security.
    java.util.concurrent.ExecutionException: UaServiceFaultException: status=Bad_SecurityChecksFailed,message=An error occurred verifying security.
        at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
        at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
        at milo_test.client.browseExample.run(browseExample.java:35)
        at milo_test.client.ClientExampleRunner.run(ClientExampleRunner.java:121)
        at milo_test.client.browseExample.main(browseExample.java:27)
    Caused by: org.eclipse.milo.opcua.stack.core.UaServiceFaultException: status=Bad_SecurityChecksFailed,description=An error occurred verifying security.
        at org.eclipse.milo.opcua.stack.client.UaStackClient.lambda$deliverResponse$5(UaStackClient.java:275)
        at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$Task.run(ExecutionQueue.java:119)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    13:07:35.420 [ForkJoinPool.commonPool-worker-1] ERROR milo_test.client.ClientExampleRunner - Error running example: UaServiceFaultException: status=Bad_SecurityChecksFailed,message=An error occurred verifying security.

如果我使用 AnonymusProvider() 或 UsernameProvider() 一切正常。

现在,基于 this 线程,我搜索了 securityTempDir,找到了服务器和客户端证书以及正确的结构(/pki -> 颁发者,拒绝和信任)但被拒绝的文件夹总是为空,无法将证书移至受信任状态。

我可能做错了什么? 感谢所有能帮助我的人!

解决方法

您将应用程序实例证书和用于身份验证的单独 X509 证书混在一起。安全和 PKI 目录是获得安全连接所必需的,但与基于 X509 的用户身份验证无关。

也就是说,我认为这可能是服务器 SDK 中的一个错误,如果您想在 GitHub 存储库中打开问题,我们可以在那里查看。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。