]>
Commit | Line | Data |
---|---|---|
cc7c72cd DB |
1 | #ifndef NSS_COMMON_H |
2 | #define NSS_COMMON_H 1 | |
3 | ||
aeb9cc10 DB |
4 | /* Used for parameters with default C++ values which are also called from C */ |
5 | #if defined(c_plusplus) || defined(__cplusplus) | |
6 | #define INIT(v,i) v = (i) | |
7 | #else | |
8 | #define INIT(v,i) v | |
9 | #endif | |
10 | ||
11 | /* These functions are called from both C and C++. */ | |
12 | #if defined(c_plusplus) || defined(__cplusplus) | |
13 | extern "C" { | |
14 | #endif | |
15 | ||
9af478a9 | 16 | #include <pk11func.h> |
fddf715d | 17 | #include <nss.h> |
52c2652f NMA |
18 | #include "config.h" |
19 | #if ENABLE_NLS | |
3cb0c273 LB |
20 | #include <libintl.h> |
21 | #include <locale.h> | |
52c2652f | 22 | #endif |
3cb0c273 LB |
23 | |
24 | #if ENABLE_NLS | |
25 | #define _(string) gettext(string) | |
26 | #define _N(string, string_plural, count) \ | |
27 | ngettext((string), (string_plural), (count)) | |
28 | #else | |
29 | #define _(string) (string) | |
30 | #define _N(string, string_plural, count) \ | |
31 | ( (count) == 1 ? (string) : (string_plural) ) | |
32 | #endif | |
33 | #define _F(format, ...) autosprintf(_(format), __VA_ARGS__) | |
34 | #define _NF(format, format_plural, count, ...) \ | |
35 | autosprintf(_N((format), (format_plural), (count)), __VA_ARGS__) | |
9af478a9 | 36 | |
aeb9cc10 DB |
37 | char *nssPasswordCallback (PK11SlotInfo *info __attribute ((unused)), |
38 | PRBool retry __attribute ((unused)), | |
39 | void *arg __attribute ((unused))); | |
40 | ||
dff24561 | 41 | SECStatus nssInit (const char *db_path, INIT (int readWrite, 0), INIT (int issueMessage, 1)); |
fddf715d SC |
42 | NSSInitContext * nssInitContext (const char *db_path, INIT (int readWrite, 0), INIT (int issueMessage, 1)); |
43 | void nssCleanup (const char *db_path, NSSInitContext *context); | |
aeb9cc10 DB |
44 | |
45 | void nsscommon_error (const char *msg, INIT(int logit, 1)); | |
2035bcd4 | 46 | void nssError (void); |
d781daa0 | 47 | |
5ab345f0 DB |
48 | PRInt32 PR_Read_Complete (PRFileDesc *fd, void *buf, PRInt32 requestedBytes); |
49 | ||
aeb9cc10 DB |
50 | #if defined(c_plusplus) || defined(__cplusplus) |
51 | } | |
52 | #endif | |
53 | ||
54 | #if defined(c_plusplus) || defined(__cplusplus) | |
55 | /* These functions are only called from C++ */ | |
56 | #include <string> | |
57 | ||
58 | const char *server_cert_nickname (); | |
59 | std::string server_cert_db_path (); | |
aeb9cc10 | 60 | std::string local_client_cert_db_path (); |
c981acd9 | 61 | std::string add_cert_db_prefix (const std::string &db_path); |
aeb9cc10 DB |
62 | |
63 | void nsscommon_error (const std::string &msg, int logit = 1); | |
64 | ||
da43562f | 65 | void start_log (const char *arg, bool redirect_clog = false); |
aeb9cc10 DB |
66 | bool log_ok (); |
67 | void log (const std::string &msg); | |
68 | void end_log (); | |
69 | ||
638abbd0 SC |
70 | bool get_host_name (CERTCertificate *c, std::string &host_name); |
71 | #ifdef HAVE_HTTP_SUPPORT | |
72 | bool cvt_nss_to_pem (CERTCertificate *c, std::string &cert_pem); | |
73 | bool get_pem_cert (const std::string &db_path, const std::string &nss_cert_name, const std::string &host, std::string &cert); | |
74 | bool have_san_match (std::string & hostname, std::string & server_cert); | |
75 | #endif | |
76 | ||
aeb9cc10 DB |
77 | int check_cert (const std::string &db_path, const std::string &nss_cert_name, bool use_db_password = false); |
78 | int gen_cert_db (const std::string &db_path, const std::string &extraDnsNames, bool use_password); | |
7209427d SC |
79 | typedef enum {db_no_nssinit, db_nssinitcontext, db_nssinit} db_init_types; |
80 | SECStatus add_client_cert (const std::string &inFileName, const std::string &db_path, db_init_types db_init_type); | |
aeb9cc10 DB |
81 | void sign_file ( |
82 | const std::string &db_path, | |
83 | const std::string &nss_cert_name, | |
84 | const std::string &inputName, | |
85 | const std::string &outputName | |
86 | ); | |
87 | ||
88 | CERTCertList *get_cert_list_from_db (const std::string &cert_nickname); | |
aeb9cc10 | 89 | |
b3367f63 | 90 | SECStatus |
cd1418c7 | 91 | read_cert_info_from_file (const std::string &certPath, |
b3367f63 DS |
92 | std::string &fingerprint); |
93 | ||
aeb9cc10 | 94 | #endif // defined(c_plusplus) || defined(__cplusplus) |
9af478a9 | 95 | |
cc7c72cd DB |
96 | #endif // NSS_COMMON_H |
97 | ||
d781daa0 | 98 | /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ |