mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
The EKMFWeb client library provides functions to communicate with an EKMF Web server via REST calls over HTTPS. EKMF Web stands for IBM Enterprise Key Management Foundation - Web Edition and is used to manage keys in an enterprise. Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
/*
|
|
* libekmfweb - EKMFWeb client library
|
|
*
|
|
* Copyright IBM Corp. 2020
|
|
*
|
|
* s390-tools is free software; you can redistribute it and/or modify
|
|
* it under the terms of the MIT license. See LICENSE for details.
|
|
*/
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
#include <openssl/evp.h>
|
|
#include <openssl/pem.h>
|
|
|
|
#include "utilities.h"
|
|
|
|
/**
|
|
* Reads a X.509 certificate from the specified PEM file.
|
|
*
|
|
* @param pem_filename the name of the PEM file to read
|
|
* @param cert on Return: the X.509 certificate object
|
|
*
|
|
* @returns zero for success, a negative errno in case of an error:
|
|
* -EINVAL: invalid parameter
|
|
* -EIO: error during reading in the certificate
|
|
* any other errno as returned by fopen
|
|
*/
|
|
int read_x509_certificate(const char *pem_filename, X509 **cert)
|
|
{
|
|
FILE *fp;
|
|
|
|
if (pem_filename == NULL || cert == NULL)
|
|
return -EINVAL;
|
|
|
|
fp = fopen(pem_filename, "r");
|
|
if (fp == NULL)
|
|
return -errno;
|
|
|
|
*cert = PEM_read_X509(fp, NULL, NULL, NULL);
|
|
|
|
fclose(fp);
|
|
|
|
if (*cert == NULL)
|
|
return -EIO;
|
|
|
|
return 0;
|
|
}
|