diff --git a/repo/fsrepo/fs_repo.c b/repo/fsrepo/fs_repo.c index 351cb7b..d073185 100644 --- a/repo/fsrepo/fs_repo.c +++ b/repo/fsrepo/fs_repo.c @@ -397,16 +397,15 @@ int fs_repo_open_config(struct FSRepo* repo) { // the next should be the array, then string "PeerID" //NOTE: the code below compares the peer id of the file with the peer id generated // by the key. If they don't match, we fail. - repo->config->identity->peer = libp2p_peer_new(); - _get_json_string_value(data, tokens, num_tokens, curr_pos, "PeerID", &repo->config->identity->peer->id); - // build the Libp2pPeer object - repo->config->identity->peer->id_size = strlen(repo->config->identity->peer->id); - repo->config->identity->peer->is_local = 1; + unsigned char* test_peer_id = NULL; + _get_json_string_value(data, tokens, num_tokens, curr_pos, "PeerID", &test_peer_id); char* priv_key_base64; // then PrivKey _get_json_string_value(data, tokens, num_tokens, curr_pos, "PrivKey", &priv_key_base64); retVal = repo_config_identity_build_private_key(repo->config->identity, priv_key_base64); - if (retVal == 0) { + if (retVal == 0 + || strlen(test_peer_id) != repo->config->identity->peer->id_size + || strcmp(test_peer_id, repo->config->identity->peer->id) != 0) { free(data); free(priv_key_base64); return 0;