1 #ifndef SSL_COMMON_H_INCLUDED
2 #define SSL_COMMON_H_INCLUDED
3 /*********************************************************************
5 * File : $Source: /cvsroot/ijbswa/current/ssl.h,v $
7 * Purpose : File with TLS/SSL extension. Contains methods for
8 * creating, using and closing TLS/SSL connections that do
9 * not depend on particular TLS/SSL library.
11 * Copyright : Written by and Copyright (c) 2017 Vaclav Svec. FIT CVUT.
13 * This program is free software; you can redistribute it
14 * and/or modify it under the terms of the GNU General
15 * Public License as published by the Free Software
16 * Foundation; either version 2 of the License, or (at
17 * your option) any later version.
19 * This program is distributed in the hope that it will
20 * be useful, but WITHOUT ANY WARRANTY; without even the
21 * implied warranty of MERCHANTABILITY or FITNESS FOR A
22 * PARTICULAR PURPOSE. See the GNU General Public
23 * License for more details.
25 * The GNU General Public License should be included with
26 * this file. If not, you can view it at
27 * http://www.gnu.org/copyleft/gpl.html
28 * or write to the Free Software Foundation, Inc., 59
29 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 *********************************************************************/
35 #define RSA_KEY_PUBLIC_EXPONENT 65537 /* Public exponent for RSA private key generating */
36 #define RSA_KEYSIZE 2048 /* Size of generated RSA keys */
37 #define ERROR_BUF_SIZE 1024 /* Size of buffer for error messages */
38 #define INVALID_CERT_INFO_BUF_SIZE 2048 /* Size of buffer for message with information about reason of certificate invalidity. Data after the end of buffer will not be saved */
39 #define KEY_FILE_TYPE ".pem"
40 #define CERT_FILE_TYPE ".crt"
42 #define CERT_PARAM_COMMON_NAME_FCODE "CN"
43 #define CERT_PARAM_ORGANIZATION_FCODE "O"
44 #define CERT_PARAM_ORG_UNIT_FCODE "OU"
45 #define CERT_PARAM_COUNTRY_FCODE "C"
46 #define CERT_PARAM_COUNTRY_CODE "CZ"
47 #define CERT_SUBJECT_PASSWORD ""
48 #define CERT_INFO_PREFIX ""
51 * Properties of cert for generating
54 char *issuer_crt; /* filename of the issuer certificate */
55 char *subject_key; /* filename of the subject key file */
56 char *issuer_key; /* filename of the issuer key file */
57 const char *subject_pwd; /* password for the subject key file */
58 const char *issuer_pwd; /* password for the issuer key file */
59 char *output_file; /* where to store the constructed key file */
60 const char *subject_name; /* subject name for certificate */
61 char issuer_name[ISSUER_NAME_BUF_SIZE]; /* issuer name for certificate */
62 const char *not_before; /* validity period not before */
63 const char *not_after; /* validity period not after */
64 const char *serial; /* serial number string */
65 int is_ca; /* is a CA certificate */
66 int max_pathlen; /* maximum CA path length */
69 extern void free_certificate_chain(struct client_state *csp);
70 extern int file_exists(const char *path);
71 extern char *make_certs_path(const char *conf_dir, const char *file_name,
73 extern unsigned long get_certificate_serial(struct client_state *csp);
74 extern int get_certificate_valid_from_date(char *buffer, size_t buffer_size, const char *fmt);
75 extern int get_certificate_valid_to_date(char *buffer, size_t buffer_size, const char *fmt);
76 extern int host_is_ip_address(const char *host);
78 #endif /* ndef SSL_COMMON_H_INCLUDED */