1
- /* $OpenBSD: ssh.c,v 1.613 2025/05/06 05:40:56 djm Exp $ */
1
+ /* $OpenBSD: ssh.c,v 1.614 2025/06/19 05:49:05 djm Exp $ */
2
2
/*
3
3
* Author: Tatu Ylonen <[email protected] >
4
4
* Copyright (c) 1995 Tatu Ylonen <[email protected] >, Espoo, Finland
@@ -513,16 +513,28 @@ resolve_canonicalize(char **hostp, int port)
513
513
static void
514
514
check_load (int r , struct sshkey * * k , const char * path , const char * message )
515
515
{
516
+ char * fp ;
517
+
516
518
switch (r ) {
517
519
case 0 :
520
+ if (k == NULL || * k == NULL )
521
+ return ;
518
522
/* Check RSA keys size and discard if undersized */
519
- if (k != NULL && * k != NULL &&
520
- (r = sshkey_check_rsa_length (* k ,
523
+ if ((r = sshkey_check_rsa_length (* k ,
521
524
options .required_rsa_size )) != 0 ) {
522
525
error_r (r , "load %s \"%s\"" , message , path );
523
526
free (* k );
524
527
* k = NULL ;
528
+ break ;
529
+ }
530
+ if ((fp = sshkey_fingerprint (* k ,
531
+ options .fingerprint_hash , SSH_FP_DEFAULT )) == NULL ) {
532
+ fatal_f ("failed to fingerprint %s %s key from %s" ,
533
+ sshkey_type (* k ), message , path );
525
534
}
535
+ debug ("loaded %s from %s: %s %s" , message , path ,
536
+ sshkey_type (* k ), fp );
537
+ free (fp );
526
538
break ;
527
539
case SSH_ERR_INTERNAL_ERROR :
528
540
case SSH_ERR_ALLOC_FAIL :
@@ -536,6 +548,8 @@ check_load(int r, struct sshkey **k, const char *path, const char *message)
536
548
error_r (r , "load %s \"%s\"" , message , path );
537
549
break ;
538
550
}
551
+ if (k != NULL && * k == NULL )
552
+ debug ("no %s loaded from %s" , message , path );
539
553
}
540
554
541
555
/*
@@ -1702,21 +1716,19 @@ main(int ac, char **av)
1702
1716
if ((o) >= sensitive_data.nkeys) \
1703
1717
fatal_f("pubkey out of array bounds"); \
1704
1718
check_load(sshkey_load_public(p, &(sensitive_data.keys[o]), NULL), \
1705
- &(sensitive_data.keys[o]), p, "pubkey"); \
1719
+ &(sensitive_data.keys[o]), p, "hostbased pubkey"); \
1706
1720
if (sensitive_data.keys[o] != NULL) { \
1707
- debug2("hostbased key %d: %s key from \"%s\"", o, \
1708
- sshkey_ssh_name(sensitive_data.keys[o]), p); \
1721
+ debug2("hostbased pubkey \"%s\" in slot %d", p, o); \
1709
1722
loaded++; \
1710
1723
} \
1711
1724
} while (0)
1712
1725
#define L_CERT (p ,o ) do { \
1713
1726
if ((o) >= sensitive_data.nkeys) \
1714
1727
fatal_f("cert out of array bounds"); \
1715
1728
check_load(sshkey_load_cert(p, &(sensitive_data.keys[o])), \
1716
- &(sensitive_data.keys[o]), p, "cert"); \
1729
+ &(sensitive_data.keys[o]), p, "hostbased cert"); \
1717
1730
if (sensitive_data.keys[o] != NULL) { \
1718
- debug2("hostbased key %d: %s cert from \"%s\"", o, \
1719
- sshkey_ssh_name(sensitive_data.keys[o]), p); \
1731
+ debug2("hostbased cert \"%s\" in slot %d", p, o); \
1720
1732
loaded++; \
1721
1733
} \
1722
1734
} while (0)
@@ -2421,9 +2433,7 @@ load_public_identity_files(const struct ssh_conn_info *cinfo)
2421
2433
continue ;
2422
2434
xasprintf (& cp , "%s-cert" , filename );
2423
2435
check_load (sshkey_load_public (cp , & public , NULL ),
2424
- & public , filename , "pubkey" );
2425
- debug ("identity file %s type %d" , cp ,
2426
- public ? public -> type : -1 );
2436
+ & public , filename , "identity pubkey" );
2427
2437
if (public == NULL ) {
2428
2438
free (cp );
2429
2439
continue ;
@@ -2452,9 +2462,7 @@ load_public_identity_files(const struct ssh_conn_info *cinfo)
2452
2462
free (cp );
2453
2463
2454
2464
check_load (sshkey_load_public (filename , & public , NULL ),
2455
- & public , filename , "certificate" );
2456
- debug ("certificate file %s type %d" , filename ,
2457
- public ? public -> type : -1 );
2465
+ & public , filename , "identity cert" );
2458
2466
free (options .certificate_files [i ]);
2459
2467
options .certificate_files [i ] = NULL ;
2460
2468
if (public == NULL ) {
0 commit comments