Skip to content

Commit 9c01de6

Browse files
committed
*SSLPrivateKeyMethod does not correctly report back signing errors
Motivation: Due a bug we did not correctly report back signing errors and just silently convert these to a success Modifications: - Explict check the result value - Set resultBytes to null on failure Result: Correctly handle signing failures
1 parent 59662a8 commit 9c01de6

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎openssl-classes/src/main/java/io/netty/internal/tcnative/SSLPrivateKeyMethodTask.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package io.netty.internal.tcnative;
1717

1818
abstract class SSLPrivateKeyMethodTask extends SSLTask implements AsyncTask {
19-
private static final byte[] EMPTY = new byte[0];
2019
private final AsyncSSLPrivateKeyMethod method;
2120

2221
// Will be accessed via JNI.
@@ -45,7 +44,7 @@ public void onSuccess(long ssl, byte[] result) {
4544
@Override
4645
public void onError(long ssl, Throwable cause) {
4746
// Return 0 as this signals back that the operation failed.
48-
resultBytes = EMPTY;
47+
resultBytes = null;
4948
callback.onResult(ssl, 0);
5049
}
5150
});

‎openssl-dynamic/src/main/c/sslcontext.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2381,12 +2381,13 @@ static enum ssl_private_key_result_t tcn_private_key_complete_java(SSL *ssl, uin
23812381
}
23822382

23832383
// The task is complete, retrieve the return value that should be signaled back.
2384+
jint returnValue = (*e)->GetIntField(e, state->ssl_task->task, sslTask_returnValue);
23842385
jbyteArray resultBytes = (*e)->GetObjectField(e, state->ssl_task->task, sslPrivateKeyMethodTask_resultBytes);
23852386

23862387
tcn_ssl_task_free(e, state->ssl_task);
23872388
state->ssl_task = NULL;
23882389

2389-
if (resultBytes == NULL) {
2390+
if (returnValue != 1 || resultBytes == NULL) {
23902391
return ssl_private_key_failure;
23912392
}
23922393

0 commit comments

Comments
 (0)