Modified vici_cert_info class for use with load_creds and vici_cred
This commit is contained in:
@@ -15,38 +15,42 @@
|
|||||||
|
|
||||||
#include "vici_cert_info.h"
|
#include "vici_cert_info.h"
|
||||||
|
|
||||||
static vici_cert_info_t vici_cert_infos[] = {
|
/**
|
||||||
{ "any", "", CERT_ANY,
|
* Legacy vici certificate types and directories created by swanctl
|
||||||
X509_NONE },
|
*/
|
||||||
{ "x509", "X.509 End Entity Certificate", CERT_X509,
|
typedef struct {
|
||||||
X509_NONE },
|
|
||||||
{ "x509ca", "X.509 CA Certificate", CERT_X509,
|
/** Certificate type string used in legacy vici messages */
|
||||||
X509_CA },
|
char *type_str;
|
||||||
{ "x509aa", "X.509 AA Certificate", CERT_X509,
|
/** Base certificate type */
|
||||||
X509_AA },
|
certificate_type_t type;
|
||||||
{ "x509ocsp", "X.509 OCSP Signer Certificate", CERT_X509,
|
/** X.509 flag */
|
||||||
X509_OCSP_SIGNER },
|
x509_flag_t flag;
|
||||||
{ "x509ac", "X.509 Attribute Certificate", CERT_X509_AC,
|
} cert_type_t;
|
||||||
X509_NONE },
|
|
||||||
{ "x509crl", "X.509 CRL", CERT_X509_CRL,
|
static cert_type_t cert_types[] = {
|
||||||
X509_NONE },
|
{ "x509", CERT_X509, X509_NONE },
|
||||||
{ "ocsp", "OCSP Response", CERT_X509_OCSP_RESPONSE,
|
{ "x509ca", CERT_X509, X509_CA },
|
||||||
X509_NONE },
|
{ "x509ocsp", CERT_X509, X509_OCSP_SIGNER },
|
||||||
{ "pubkey", "Raw Public Key", CERT_TRUSTED_PUBKEY,
|
{ "x509aa", CERT_X509, X509_AA },
|
||||||
X509_NONE }
|
{ "x509ac", CERT_X509_AC, X509_NONE },
|
||||||
|
{ "x509crl", CERT_X509_CRL, X509_NONE },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* See header. */
|
bool vici_cert_info_from_str(char *type_str, certificate_type_t *type,
|
||||||
vici_cert_info_t* vici_cert_info_retrieve(char *type_str)
|
x509_flag_t *flag)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < countof(vici_cert_infos); i++)
|
for (i = 0; i < countof(cert_types); i++)
|
||||||
{
|
{
|
||||||
if (strcaseeq(type_str, vici_cert_infos[i].type_str))
|
if (strcaseeq(type_str, cert_types[i].type_str))
|
||||||
{
|
{
|
||||||
return &vici_cert_infos[i];
|
*type = cert_types[i].type;
|
||||||
|
*flag = cert_types[i].flag;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,39 +26,7 @@ typedef struct vici_cert_info_t vici_cert_info_t;
|
|||||||
#include <credentials/certificates/certificate.h>
|
#include <credentials/certificates/certificate.h>
|
||||||
#include <credentials/certificates/x509.h>
|
#include <credentials/certificates/x509.h>
|
||||||
|
|
||||||
/**
|
bool vici_cert_info_from_str(char *type_str, certificate_type_t *type,
|
||||||
* Information on vici certificate types
|
x509_flag_t *flag);
|
||||||
*/
|
|
||||||
struct vici_cert_info_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Certificate type string used in vici messages
|
|
||||||
*/
|
|
||||||
char *type_str;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Caption describing the certificate type
|
|
||||||
*/
|
|
||||||
char *caption;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base certificate type
|
|
||||||
*/
|
|
||||||
certificate_type_t type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* X.509 flag
|
|
||||||
*/
|
|
||||||
x509_flag_t flag;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve information on a given certificate type
|
|
||||||
*
|
|
||||||
* @param type_str Vici certificate type string
|
|
||||||
* @return Information record or NULL if not found
|
|
||||||
*/
|
|
||||||
vici_cert_info_t* vici_cert_info_retrieve(char *type_str);
|
|
||||||
|
|
||||||
#endif /** VICI_CERT_INFO_H_ @}*/
|
#endif /** VICI_CERT_INFO_H_ @}*/
|
||||||
|
|||||||
Reference in New Issue
Block a user