Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore ability to use RSA CA with Fabric MSP #2121

Merged
merged 3 commits into from Nov 17, 2020

Conversation

sykesm
Copy link
Contributor

@sykesm sykesm commented Nov 13, 2020

While RSA has never been supported by Fabric for transaction signing and verification, prior to version 2.x, MSPs could include CA certificates that included RSA public keys. This was broken with the removal of the unsupported RSA code.

This change modifies the key import function used by the MSP to convert an RSA public key to a bccsp.Key that can then be used as part of an MSP identity.

This code does not add support for RSA on transaction paths.

@sykesm sykesm changed the title Rsa ca master Restore ability to use RSA CA with Fabric MSP Nov 13, 2020
@sykesm sykesm marked this pull request as ready for review November 13, 2020 21:48
@sykesm sykesm requested a review from a team as a code owner November 13, 2020 21:48
network.Peer("Org2", "peer0"),
)
nwo.DeployChaincode(network, "testchannel", orderer, chaincode)
RunQueryInvokeQuery(network, orderer, org1Peer0, 100)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about fetching the channel config and ensuring that the CAs are indeed RSA?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go for it. Since they were explicitly generated by the code below the test and the test failed before changing the production code (ie test-driven), I personally don't see the value.

Copy link
Contributor

@ale-linux ale-linux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Matt! I'm just wondering whether it'd be actually better to exercise the existing e2e integration tests (e.g. those in integration/e2e/e2e_test.go) with the only difference that one of the CAs uses RSA. Also, shouldn't we test whether such a channel is upgradable?

// where the CAs use RSA keys and everything else is ECDSA. It's not
// pretty but it gets the job done for testing.

func generateRSACACrypto(n *nwo.Network) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I don't understand why we are essentially replicating what cryptogen is doing only with RSA CAs.
Isn't it simpler to:

  1. Run cryptogen
  2. Locate all CAs, replace their public key and re-sign them.
  3. Locate all certificate, replace their signature with a new signature
    ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This started out with the assumption that RSA was used throughout the MSP so this code generated an entire MSP tree with RSA. When it became clear that signing certificates could not use RSA, I changed that path to use ECDSA. As you can see, that resulted in the introduction of generateECKey and a call to it from one site.

As the comment at the top of the code says, "It's not pretty but it gets the job done for testing." I stand by that. Changing this to walk through all of the crypto directories to re-sign certificates is nearly as complicated as what's here. What's here now works, is self-contained, and isolated to the single test that needs it. I do not believe rewriting it to parse and re-sign certs is worth the effort.

Expect(err).NotTo(HaveOccurred())
writeCertificate(filepath.Join(tlsDir, "ca.crt"), tlsCA.certBytes)

tlsKey := generateRSAKey()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand you're testing this, but why is this needed? BCCSP never processes any TLS certificates so the production code change is not affecting this part of the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in the integration tests RSA TLS certificates. Since this test is explicitly targeted to RSA, it seemed reasonable to have something here to help prevent future regressions.

While RSA has never been supported by Fabric for transaction signing and
verification, prior to version 2.x, MSPs could include CA certificates
that included RSA public keys. This was broken with the removal of the
unsupported RSA code.

This change modifies the key import function used by the MSP to convert
an RSA public key to a bccsp.Key that can then be used as part of an MSP
identity.

This code does *not* add support for RSA on transaction paths.

Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants