Skip to content

Fix regression in SslContext private key loading#12743

Merged
normanmaurer merged 1 commit intonetty:4.1from
chrisvest:4.1-bcpem
Aug 27, 2022
Merged

Fix regression in SslContext private key loading#12743
normanmaurer merged 1 commit intonetty:4.1from
chrisvest:4.1-bcpem

Conversation

@chrisvest
Copy link
Copy Markdown
Member

Motivation:
The BouncyCastlePemReader checked that the bcprov dependency was available, but not the bcpkix dependency, which is also required to use the Bouncy Castle PEM reader.
This means SslContext could be tricked into using Bouncy Castle for PEM reading, when the required classes were not actually available.

Modification:
Add another check for bcpkix, and avoid using Bouncy Castle for PEM reading if its PEMReader is not available.

Result:
We no longer get the following exception:

java.lang.NoClassDefFoundError: org/bouncycastle/openssl/PEMParser
	at io.netty.handler.ssl.BouncyCastlePemReader.newParser(BouncyCastlePemReader.java:203)
	at io.netty.handler.ssl.BouncyCastlePemReader.getPrivateKey(BouncyCastlePemReader.java:134)
	at io.netty.handler.ssl.SslContext.toPrivateKey(SslContext.java:1126)

Motivation:
The BouncyCastlePemReader checked that the bcprov dependency was available, but not the bcpkix dependency, which is also required to use the Bouncy Castle PEM reader.
This means SslContext could be tricked into using  Bouncy Castle for PEM reading, when the required classes were not actually available.

Modification:
Add another check for bcpkix, and avoid using Bouncy Castle for PEM reading if its PEMReader is not available.

Result:
We no longer get the following exception:

```
java.lang.NoClassDefFoundError: org/bouncycastle/openssl/PEMParser
	at io.netty.handler.ssl.BouncyCastlePemReader.newParser(BouncyCastlePemReader.java:203)
	at io.netty.handler.ssl.BouncyCastlePemReader.getPrivateKey(BouncyCastlePemReader.java:134)
	at io.netty.handler.ssl.SslContext.toPrivateKey(SslContext.java:1126)
```
@chrisvest chrisvest added this to the 4.1.81.Final milestone Aug 26, 2022
@chrisvest chrisvest requested a review from normanmaurer August 26, 2022 20:35
@normanmaurer normanmaurer merged commit f53a5ef into netty:4.1 Aug 27, 2022
normanmaurer pushed a commit that referenced this pull request Aug 27, 2022
Motivation:
The BouncyCastlePemReader checked that the bcprov dependency was available, but not the bcpkix dependency, which is also required to use the Bouncy Castle PEM reader.
This means SslContext could be tricked into using  Bouncy Castle for PEM reading, when the required classes were not actually available.

Modification:
Add another check for bcpkix, and avoid using Bouncy Castle for PEM reading if its PEMReader is not available.

Result:
We no longer get the following exception:

```
java.lang.NoClassDefFoundError: org/bouncycastle/openssl/PEMParser
	at io.netty.handler.ssl.BouncyCastlePemReader.newParser(BouncyCastlePemReader.java:203)
	at io.netty.handler.ssl.BouncyCastlePemReader.getPrivateKey(BouncyCastlePemReader.java:134)
	at io.netty.handler.ssl.SslContext.toPrivateKey(SslContext.java:1126)
```
@chrisvest chrisvest deleted the 4.1-bcpem branch August 27, 2022 15:18
Scottmitch added a commit to Scottmitch/servicetalk-1 that referenced this pull request Aug 30, 2022
This reverts commit a0c8d61.

We anticipate another release before updating Netty versions,
and there is a Netty issue that may impact ServiceTalk users:
netty/netty#12743.
Scottmitch added a commit to apple/servicetalk that referenced this pull request Aug 30, 2022
This reverts commit a0c8d61.

We anticipate another release before updating Netty versions,
and there is a Netty issue that may impact ServiceTalk users:
netty/netty#12743.
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.

2 participants