OpenSSL
1.0.1c
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
demos
maurice
loadkeys.c
Go to the documentation of this file.
1
/* NOCW */
2
/*
3
Please read the README file for condition of use, before
4
using this software.
5
6
Maurice Gittens <
[email protected]
> January 1997
7
8
*/
9
10
#include <unistd.h>
11
#include <stdio.h>
12
#include <netinet/in.h>
13
#include <fcntl.h>
14
#include <strings.h>
15
#include <stdlib.h>
16
17
#include <
openssl/rsa.h
>
18
#include <
openssl/evp.h
>
19
#include <
openssl/objects.h
>
20
#include <
openssl/x509.h
>
21
#include <
openssl/err.h
>
22
#include <
openssl/pem.h
>
23
#include <
openssl/ssl.h
>
24
25
EVP_PKEY
*
ReadPublicKey
(
const
char
*certfile)
26
{
27
FILE *
fp
= fopen (certfile,
"r"
);
28
X509
*x509;
29
EVP_PKEY
*pkey;
30
31
if
(!fp)
32
return
NULL;
33
34
x509 = PEM_read_X509(fp, NULL, 0, NULL);
35
36
if
(x509 == NULL)
37
{
38
ERR_print_errors_fp
(stderr);
39
return
NULL;
40
}
41
42
fclose (fp);
43
44
pkey=
X509_extract_key
(x509);
45
46
X509_free(x509);
47
48
if
(pkey == NULL)
49
ERR_print_errors_fp
(stderr);
50
51
return
pkey;
52
}
53
54
EVP_PKEY
*
ReadPrivateKey
(
const
char
*keyfile)
55
{
56
FILE *
fp
= fopen(keyfile,
"r"
);
57
EVP_PKEY
*pkey;
58
59
if
(!fp)
60
return
NULL;
61
62
pkey =
PEM_read_PrivateKey
(fp, NULL, 0, NULL);
63
64
fclose (fp);
65
66
if
(pkey == NULL)
67
ERR_print_errors_fp
(stderr);
68
69
return
pkey;
70
}
71
72
Generated on Thu Jan 10 2013 09:53:41 for OpenSSL by
1.8.2