summaryrefslogtreecommitdiff
path: root/authfile.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-06-05 20:46:32 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-06-05 20:46:32 +0000
commit322915d5e4786ab60dd94766d602ddb8c0e31168 (patch)
tree84c0ae6bc37a060d7c65d96377c29def96b892ef /authfile.c
parent3b89c5ef8988ae33621efef8bd117db8f1f47e35 (diff)
- markus@cvs.openbsd.org 2001/05/28 10:08:55
[authfile.c] key_load_private: set comment to filename for PEM keys
Diffstat (limited to 'authfile.c')
-rw-r--r--authfile.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/authfile.c b/authfile.c
index 2715bdef8..e1a9a21a1 100644
--- a/authfile.c
+++ b/authfile.c
@@ -36,7 +36,7 @@
36 */ 36 */
37 37
38#include "includes.h" 38#include "includes.h"
39RCSID("$OpenBSD: authfile.c,v 1.33 2001/05/16 20:51:57 markus Exp $"); 39RCSID("$OpenBSD: authfile.c,v 1.34 2001/05/28 10:08:55 markus Exp $");
40 40
41#include <openssl/err.h> 41#include <openssl/err.h>
42#include <openssl/evp.h> 42#include <openssl/evp.h>
@@ -543,7 +543,7 @@ Key *
543key_load_private(const char *filename, const char *passphrase, 543key_load_private(const char *filename, const char *passphrase,
544 char **commentp) 544 char **commentp)
545{ 545{
546 Key *pub; 546 Key *pub, *prv;
547 int fd; 547 int fd;
548 548
549 fd = open(filename, O_RDONLY); 549 fd = open(filename, O_RDONLY);
@@ -558,14 +558,17 @@ key_load_private(const char *filename, const char *passphrase,
558 lseek(fd, (off_t) 0, SEEK_SET); /* rewind */ 558 lseek(fd, (off_t) 0, SEEK_SET); /* rewind */
559 if (pub == NULL) { 559 if (pub == NULL) {
560 /* closes fd */ 560 /* closes fd */
561 return key_load_private_pem(fd, KEY_UNSPEC, passphrase, 561 prv = key_load_private_pem(fd, KEY_UNSPEC, passphrase, NULL);
562 commentp); 562 /* use the filename as a comment for PEM */
563 if (commentp && prv)
564 commentp = xstrdup(filename);
563 } else { 565 } else {
564 /* it's a SSH v1 key if the public key part is readable */ 566 /* it's a SSH v1 key if the public key part is readable */
565 key_free(pub); 567 key_free(pub);
566 /* closes fd */ 568 /* closes fd */
567 return key_load_private_rsa1(fd, filename, passphrase, NULL); 569 prv = key_load_private_rsa1(fd, filename, passphrase, NULL);
568 } 570 }
571 return prv;
569} 572}
570 573
571int 574int