mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
pki: Make sure public keys match when adding certificate data
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
committed by
Sahana Prasad
parent
a8c844c9c2
commit
d604d7f872
@@ -2162,7 +2162,7 @@ int ssh_pki_export_pubkey_file(const ssh_key key,
|
|||||||
**/
|
**/
|
||||||
int ssh_pki_copy_cert_to_privkey(const ssh_key certkey, ssh_key privkey) {
|
int ssh_pki_copy_cert_to_privkey(const ssh_key certkey, ssh_key privkey) {
|
||||||
ssh_buffer cert_buffer;
|
ssh_buffer cert_buffer;
|
||||||
int rc;
|
int rc, cmp;
|
||||||
|
|
||||||
if (certkey == NULL || privkey == NULL) {
|
if (certkey == NULL || privkey == NULL) {
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
@@ -2176,6 +2176,12 @@ int ssh_pki_copy_cert_to_privkey(const ssh_key certkey, ssh_key privkey) {
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* make sure the public keys match */
|
||||||
|
cmp = ssh_key_cmp(certkey, privkey, SSH_KEY_CMP_PUBLIC);
|
||||||
|
if (cmp != 0) {
|
||||||
|
return SSH_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
cert_buffer = ssh_buffer_new();
|
cert_buffer = ssh_buffer_new();
|
||||||
if (cert_buffer == NULL) {
|
if (cert_buffer == NULL) {
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user