Yet Another Intercepting Proxy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

114 lines
2.6 KiB

#ifndef SSL_H
#define SSL_H
#include <openssl/ossl_typ.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <stdlib.h>
#include "config.h"
typedef struct CertList CertList;
struct CertList {
char *host;
EVP_PKEY *key;
X509 *cert;
CertList *next;
};
typedef struct {
X509 *cert;
EVP_PKEY *pkey;
CertList *certs;
} CertificateAutority;
SSL_CTX* setup_ctx(CertList *certItem);
/*
* generate_ca_key
* Genreates a EVP_PKEY for the certificate authority
*/
EVP_PKEY* generate_ca_key();
/*
* generate_ca_cert
* Genreates a x509 cert for the certificate authority
* @param EVP_PKEY pkey - the pkey for the ca
*/
X509* generate_ca_cert(EVP_PKEY * pkey);
/*
* generate_site_cert
* Genreates a signed x509 cert for the host authority
* @param EVP_PKEY pkey - the pkey for the ca
* @param X509 caCert - the cert for the ca
* @param char* host - the common name for the certificate
*/
X509* generate_site_cert( EVP_PKEY *pkey, X509 *caCert, char *host );
/*
* create_and_save_key
* Genreates a EVP_PKEY for the CA and saves it
* @param char[] keyfile - the name of the file
*/
bool create_and_save_key(char keyfile[]);
/*
* create_and_save_cert
* Genreates a cert for the CA and saves it
* @param char[] certfile - the name of the file
* @param EVP_PKEY pkey - the pkey for the ca
*/
bool create_and_save_cert(char certfile[], EVP_PKEY *pkey);
/*
* read_private_key
* Reades a priveate key from the keyfile
* @param char[] keyfile - the name of the file
*/
EVP_PKEY* read_private_key(char keyfile[]);
/*
* read_cert
* Reades a cert from the certfile
* @param char[] certfile - the name of the file
*/
X509* read_cert(char certfile[]);
/*
* newCertListItem
* Creates an element of the CertList linked list
* @param char* host - the common name for the certificate
* @param EVP_PKEY key - the pkey
* @param X509 cert - the cert
*/
CertList *newCertListItem(char *host, EVP_PKEY *key, X509 *cert);
/*
* getLastCertListItem
* Gets the last element in the linked list
* @param CertList item - An item in the linked list
*/
CertList *getLastCertListItem(CertList *item);
/*
* countCertListItems
* counts the elements in the linked list
* @param CertList item - the first item in the linked list
*/
unsigned int countCertListItems(CertList *item);
/*
* countCertListItems
* Returns the certList item with the specified host
* @param CertList item - the first item in the linked list
* @param char* host - the host we are looking for
* returns null if not there
*/
CertList *findCertListItem( CertList *item, char *host );
#endif /* ifndef SSL_ */