Only read our public key if it wasn't already in the private key file.
This commit is contained in:
parent
a67a21ef3c
commit
a92c471a2b
1 changed files with 9 additions and 7 deletions
|
@ -150,17 +150,23 @@ bool read_rsa_public_key(connection_t *c)
|
||||||
bool read_rsa_private_key(void)
|
bool read_rsa_private_key(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *fname, *key;
|
char *fname, *key, *pubkey;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
if(get_config_string(lookup_config(config_tree, "PrivateKey"), &key)) {
|
if(get_config_string(lookup_config(config_tree, "PrivateKey"), &key)) {
|
||||||
|
if(!get_config_string(lookup_config(myself->connection->config_tree, "PublicKey"), &pubkey)) {
|
||||||
|
logger(LOG_ERR, _("PrivateKey used but no PublicKey found!"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
myself->connection->rsa_key = RSA_new();
|
myself->connection->rsa_key = RSA_new();
|
||||||
// RSA_blinding_on(myself->connection->rsa_key, NULL);
|
// RSA_blinding_on(myself->connection->rsa_key, NULL);
|
||||||
BN_hex2bn(&myself->connection->rsa_key->d, key);
|
BN_hex2bn(&myself->connection->rsa_key->d, key);
|
||||||
|
BN_hex2bn(&myself->connection->rsa_key->n, pubkey);
|
||||||
BN_hex2bn(&myself->connection->rsa_key->e, "FFFF");
|
BN_hex2bn(&myself->connection->rsa_key->e, "FFFF");
|
||||||
free(key);
|
free(key);
|
||||||
|
free(pubkey);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,19 +248,15 @@ bool setup_myself(void)
|
||||||
myself->name = name;
|
myself->name = name;
|
||||||
myself->connection->name = xstrdup(name);
|
myself->connection->name = xstrdup(name);
|
||||||
|
|
||||||
if(!read_rsa_private_key())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(!read_connection_config(myself->connection)) {
|
if(!read_connection_config(myself->connection)) {
|
||||||
logger(LOG_ERR, _("Cannot open host configuration file for myself!"));
|
logger(LOG_ERR, _("Cannot open host configuration file for myself!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!read_rsa_public_key(myself->connection))
|
if(!read_rsa_private_key())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!get_config_string
|
if(!get_config_string(lookup_config(myself->connection->config_tree, "Port"), &myport))
|
||||||
(lookup_config(myself->connection->config_tree, "Port"), &myport))
|
|
||||||
asprintf(&myport, "655");
|
asprintf(&myport, "655");
|
||||||
|
|
||||||
/* Read in all the subnets specified in the host configuration file */
|
/* Read in all the subnets specified in the host configuration file */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue