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

Workaround for regex bug in Android SDK #13695

Merged
merged 1 commit into from Nov 13, 2023

Conversation

fishb1
Copy link
Contributor

@fishb1 fishb1 commented Nov 10, 2023

Motivation:

If Netty is started from an Android app and certificate/private key are passed into the builder as input streams, an error occurs: org.conscrypt.OpenSSLX509CertificateFactory: org.conscrypt.OpenSSLX509CertificateFactory: java.lang.RuntimeException: error:0c0000a2:ASN.1 encoding routines:OPENSSL_internal:NOT_ENOUGH_DATA

Due to a bug in the regex implementation in Android SDK, the certificate is parsed from the input stream as BEGIN and further creating of the X.509 certificate fails.

See https://issuetracker.google.com/issues/293206296

Modifications:

The end position of the latest match is saved into a variable and used as the start position for the next match as a workaround for the bug.

Result:

Fixes #13515

Netty starts on Android without an error.

@normanmaurer
Copy link
Member

@fishb1 I think the mentioned issue on the Fixes is incorrect.

@fishb1
Copy link
Contributor Author

fishb1 commented Nov 10, 2023

@fishb1 I think the mentioned issue on the Fixes is incorrect.

Oops, sorry! Fixed.

Motivation:

If Netty is started from an Android app and certificate/private key are passed into the builder as input streams, an error occurs:
org.conscrypt.OpenSSLX509CertificateFactory: org.conscrypt.OpenSSLX509CertificateFactory: java.lang.RuntimeException: error:0c0000a2:ASN.1 encoding routines:OPENSSL_internal:NOT_ENOUGH_DATA

Due to a bug in the regex implementation in Android SDK, the certificate is parsed from the input stream as BEGIN and further creating of the X.509 certificate fails.

See https://issuetracker.google.com/issues/293206296

Modifications:

The end position of the latest match is saved into a variable and used as the start position for the next match as a workaround for the bug.

Result:

Netty starts on Android without an error.
@fishb1 fishb1 force-pushed the 13515_fix_android_cert_parsing branch from b074116 to 50fac0c Compare November 10, 2023 09:12
@normanmaurer
Copy link
Member

@fishb1 did you sign our icla yet ? https://netty.io/s/icla

@normanmaurer normanmaurer added this to the 4.1.102.Final milestone Nov 10, 2023
@fishb1
Copy link
Contributor Author

fishb1 commented Nov 10, 2023

@fishb1 did you sign our icla yet ? https://netty.io/s/icla

Yes, I did.

@normanmaurer normanmaurer merged commit 2241f82 into netty:4.1 Nov 13, 2023
14 checks passed
normanmaurer pushed a commit that referenced this pull request Nov 13, 2023
Motivation:

If Netty is started from an Android app and certificate/private key are
passed into the builder as input streams, an error occurs:
org.conscrypt.OpenSSLX509CertificateFactory:
org.conscrypt.OpenSSLX509CertificateFactory: java.lang.RuntimeException:
error:0c0000a2:ASN.1 encoding routines:OPENSSL_internal:NOT_ENOUGH_DATA

Due to a bug in the regex implementation in Android SDK, the certificate
is parsed from the input stream as BEGIN and further creating of the
X.509 certificate fails.

See https://issuetracker.google.com/issues/293206296

Modifications:

The end position of the latest match is saved into a variable and used
as the start position for the next match as a workaround for the bug.

Result:

Fixes #13515

Netty starts on Android without an error.
@fishb1 fishb1 deleted the 13515_fix_android_cert_parsing branch November 13, 2023 08:54
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.

SSL certificate parsing issue when upgrading beyond 4.1.78 on Android
3 participants