Skip to content

Commit

Permalink
Issue 1079 (esnet#1091)
Browse files Browse the repository at this point in the history
* docs: Add a few notes about RSA key formats used for auth.

* enh(auth): If we can't read key files, emit appropriate OpenSSL error.

Fixes esnet#1079.
  • Loading branch information
bmah888 authored and hanvari committed Jul 3, 2021
1 parent 77dafba commit 6834f61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/iperf3.1
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,11 @@ path to the RSA public key used to encrypt authentication credentials
The authentication feature of iperf3 requires an RSA public keypair.
The public key is used to encrypt the authentication token containing the
user credentials, while the private key is used to decrypt the authentication token.
An example of a set of UNIX/Linux commands to generate correct keypair follows:
The private key must be in PEM format and additionally must not have a
password set.
The public key must be in PEM format and use SubjectPrefixKeyInfo encoding.
An example of a set of UNIX/Linux commands using OpenSSL
to generate a correctly-formed keypair follows:
.sp 1
.in +.5i
> openssl genrsa -des3 -out private.pem 2048
Expand Down
3 changes: 3 additions & 0 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#include "version.h"
#if defined(HAVE_SSL)
#include <openssl/bio.h>
#include <openssl/err.h>
#include "iperf_auth.h"
#endif /* HAVE_SSL */

Expand Down Expand Up @@ -1397,6 +1398,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
return -1;
}
if (test_load_pubkey_from_file(client_rsa_public_key) < 0){
iperf_err(test, "%s\n", ERR_error_string(ERR_get_error(), NULL));
i_errno = IESETCLIENTAUTH;
return -1;
}
Expand All @@ -1421,6 +1423,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
} else if (test->role == 's' && server_rsa_private_key) {
test->server_rsa_private_key = load_privkey_from_file(server_rsa_private_key);
if (test->server_rsa_private_key == NULL){
iperf_err(test, "%s\n", ERR_error_string(ERR_get_error(), NULL));
i_errno = IESETSERVERAUTH;
return -1;
}
Expand Down

0 comments on commit 6834f61

Please sign in to comment.