Warm tip: This article is reproduced from stackoverflow.com, please click
corda

Failed to find a store at certificates\sslkeystore.jks

发布于 2020-05-03 16:09:35

Corda open source on Linux. Node RPC SSL enabled. I am getting error "Failed to find a store at certificates\sslkeystore.jks". Any ideas? I have entered absolute path in keyStorePath.

Questioner
Ashish Sinha
Viewed
31
Adel Rustum 2020-02-16 07:30

You must follow the steps of this paragraph: https://docs.corda.net/clientrpc.html#wire-security which I detailed for you below.

When you enable RPC SSL, you must run this command one time (you will be asked to supply 2 new passwords):

java -jar corda.jar generate-rpc-ssl-settings

It will create the rpcsslkeystore.jks under certificates folder, and rpcssltruststore.jks under certificates/export folder.
Inside your node.conf supply the path and password of rpcsslkeystore.jks:

rpcSettings {
    useSsl=true
    ssl {
       keyStorePath=${baseDirectory}/certificates/rpcsslkeystore.jks
       keyStorePassword=password
    }
    standAloneBroker = false
    address = "0.0.0.0:10003"
    adminAddress = "0.0.0.0:10004"
}

Now if you have a webserver, inside NodeRPCConnection you must use the constructor that takes a ClientRpcSslOptions parameter:

// RPC SSL properties.
@Value("${config.rpc.ssl.truststorepath}")
private String trustStorePath;
@Value("${config.rpc.ssl.truststorepassword}")
private String trustStorePassword;

@PostConstruct
public void initialiseNodeRPCConnection() {
    NetworkHostAndPort rpcAddress = new NetworkHostAndPort(host, rpcPort);
    ClientRpcSslOptions clientRpcSslOptions = new ClientRpcSslOptions(Paths.get(trustStorePath),
            trustStorePassword, "JKS");
    CordaRPCClient rpcClient = new CordaRPCClient(rpcAddress, clientRpcSslOptions, null);
    rpcConnection = rpcClient.start(username, password);
    proxy = rpcConnection.getProxy();
}

We added above 2 extra attributes that you must now supply when starting the webserver, for that; modify your clients module build.gradle:

task runNodeServer(type: JavaExec, dependsOn: jar) {
    classpath = sourceSets.main.runtimeClasspath
    main = 'com.example.server.ServerKt'
    args '--server.port=50005', '--config.rpc.host=localhost', 
    '--config.rpc.port=10005', '--config.rpc.username=user1', '--config.rpc.password=test',
    '--config.rpc.ssl.truststorepath=/path-to-project/build/nodes/your-node/certificates/export/rpcssltruststore.jks', 
    '--config.rpc.ssl.truststorepassword=password'
}

If you're planning to connect to the node with a standalone shell, you must do something similar, but it didn't work for me; I reported the following bug: https://github.com/corda/corda/issues/5955