Coder Social home page Coder Social logo

Comments (5)

irririki avatar irririki commented on July 29, 2024 1

Happy to do so.

from fabric-sdk-java.

irririki avatar irririki commented on July 29, 2024

By changing the code in NetworkConfig.java to match the certFile and keyFile key names, it works. I have tested with my local fix.

if (keyfile != null) {
    props.put("clientKeyFile", keyfile);
}

if (certfile != null) {
    props.put("clientCertFile", certfile);
}

from fabric-sdk-java.

bestbeforetoday avatar bestbeforetoday commented on July 29, 2024

This looks like something that has never worked, and perhaps wasn't intended to. The change you refer to just introduced some new functionality and didn't change any existing property naming set by NetworkConfig. It seems by happy coincidence that it would provide the capability you are looking for too though.

The Endpoint code is picking up properties set either explicitly if nodes are programmatically added, or from configuration and/or environment variables when nodes are added by service discovery, here:

  • Peer:
    String clientCertFile = (String) findClientProp(config, "clientCertFile", mspid, endpoint, null);
    byte[] clientCertBytes = (byte[]) findClientProp(config, "clientCertBytes", mspid, endpoint, null);
    if (null != clientCertBytes) {
    properties.put("clientCertBytes", clientCertBytes);
    } else if (null != clientCertFile) {
    properties.put("clientCertFile", clientCertFile);
    }
    properties.put(Peer.PEER_ORGANIZATION_MSPID_PROPERTY, sdPeerAddition.getMspId());
    byte[] clientKeyBytes = (byte[]) findClientProp(config, "clientKeyBytes", mspid, endpoint, null);
    String clientKeyFile = (String) findClientProp(config, "clientKeyFile", mspid, endpoint, null);
    if (null != clientKeyBytes) {
    properties.put("clientKeyBytes", clientKeyBytes);
    } else if (null != clientKeyFile) {
    properties.put("clientKeyFile", clientKeyFile);
    }
  • Orderer:
    String clientCertFile = (String) findClientProp(config, "clientCertFile", mspid, endpoint, null);
    if (null != clientCertFile) {
    properties.put("clientCertFile", clientCertFile);
    }
    String clientKeyFile = (String) findClientProp(config, "clientKeyFile", mspid, endpoint, null);
    if (null != clientKeyFile) {
    properties.put("clientKeyFile", clientKeyFile);
    }
    byte[] clientCertBytes = (byte[]) findClientProp(config, "clientCertBytes", mspid, endpoint, null);
    if (null != clientCertBytes) {
    properties.put("clientCertBytes", clientCertBytes);
    }
    byte[] clientKeyBytes = (byte[]) findClientProp(config, "clientKeyBytes", mspid, endpoint, null);
    if (null != clientKeyBytes) {
    properties.put("clientKeyBytes", clientKeyBytes);
    }

Your suggested enhancement seems reasonable, although I think "tlsClientKeyFile", "tlsClientCertFile", "tlsClientKeyBytes" and "tlsClientCertBytes" would all need to change to the forms without the leading "tls" to match the Endpoint code. Note that these properties are also used in HFClient, here:

String tlsClientKeyFile = properties.getProperty("tlsClientKeyFile");
String tlsClientCertFile = properties.getProperty("tlsClientCertFile");
byte[] tlsClientKeyAsBytes = (byte[]) properties.get("tlsClientKeyBytes");
if (tlsClientKeyFile != null && tlsClientKeyAsBytes != null) {
logger.warn("SSL CA client key is specified as bytes and as a file path. Using client key specified as bytes.");
}
if (tlsClientKeyFile != null && tlsClientKeyAsBytes == null) {
tlsClientKeyAsBytes = Files.readAllBytes(Paths.get(tlsClientKeyFile));
}
byte[] tlsClientCertAsBytes = (byte[]) properties.get("tlsClientCertBytes");

I think the changes required would be:

  • Change "tlsClient..." properties set in NetworkConfig to "client...".
  • Change the corresponding property names in HFCAClient.
  • Some unit testing (at least in NetworkConfigTest).
  • Extract the strings hard-coded in all these locations to internal constants, probably in Endpoint

Would you like to implement these changes?

from fabric-sdk-java.

irririki avatar irririki commented on July 29, 2024

@bestbeforetoday I have made the changes, but it seems that I can't create a new pull request. Could you have a look?

https://github.com/irririki/fabric-sdk-java-260

  • Change "tlsClient..." properties set in NetworkConfig to "client...".
  • Change the corresponding property names in HFCAClient.
  • Some unit testing (at least in NetworkConfigTest).
    NetworkConfigTest and HFCAClientTest.java
  • Extract the strings hard-coded in all these locations to internal constants, probably in Endpoint
    except in NetworkConfig and HFCAClient. I feel that it's better to pass the config around and define constants there, but that'd require some big changes.
[WARNING] Tests run: 444, Failures: 0, Errors: 0, Skipped: 5

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  35.443 s
[INFO] Finished at: 2023-02-07T12:14:03+09:00
[INFO] ------------------------------------------------------------------------

from fabric-sdk-java.

bestbeforetoday avatar bestbeforetoday commented on July 29, 2024

I think the problem might be that your repository is not a fork if this repository. The repository with your changes needs to be a fork of the repository to which you want to propose changes by creating a pull request. See the GitHub documentation on how to fork a repo. Then the documentation on creating a pull request from a fork.

from fabric-sdk-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.