+ if(result)
+ return 0;
+ else
+ {
+ syslog(LOG_ERR, _("No public key for %s specified!"), c->name);
+ return -1;
+ }
+}
+
+int read_rsa_private_key(void)
+{
+ FILE *fp;
+ void *result;
+ char *fname, *key;
+cp
+ if(!myself->connection->rsa_key)
+ myself->connection->rsa_key = RSA_new();
+
+ if(get_config_string(lookup_config(config_tree, "PrivateKey"), &key))
+ {
+ BN_hex2bn(&myself->connection->rsa_key->d, key);
+ BN_hex2bn(&myself->connection->rsa_key->e, "FFFF");
+ }
+ else if(get_config_string(lookup_config(config_tree, "PrivateKeyFile"), &fname))
+ {
+ if((fp = fopen(fname, "r")) == NULL)
+ {
+ syslog(LOG_ERR, _("Error reading RSA private key file `%s': %m"),
+ fname);
+ return -1;
+ }
+ result = PEM_read_RSAPrivateKey(fp, &myself->connection->rsa_key, NULL, NULL);
+ fclose(fp);
+ if(!result)
+ {
+ syslog(LOG_ERR, _("Reading RSA private key file `%s' failed: %m"),
+ fname);
+ return -1;
+ }
+ }
+ else
+ {
+ syslog(LOG_ERR, _("No private key for tinc daemon specified!"));
+ return -1;
+ }