keygen/src/ssl.c
/**
 * write_x509_cert() - Write an X509 cert to a file
 * @cert: The certificate to write
 * @fname: A string containing the name of the file to write into
 *
 * Return: None
 */
Write an X509 cert to a file
@cert: The certificate to write
@fname: A string containing the name of the file to write into

None
Write an X509 cert to a file @cert : The certificate to write @fname : A string containing the name of the file to write into None
int write_cert(const struct key *key_in, const char *cn, const char *fname)
{
    X509 *cert = NULL;
    FILE *f = NULL;
    int ret = 0;
    cert = gen_signed_cert(key_in->pkey, cn);
    if (!cert) {
        fprintf(stderr, "%s generate signed cert", __func__);
        ret = 0;
        goto out;
    }
    f = fopen(fname, "w");
    if (!f) {
        fprintf(stderr, "%s could not open %s, fopen error=%d", __func__, fname, errno);
        ret = 0;
        goto cleanup;
    }
    ret = PEM_write_X509(f, cert);
    if (!ret) {
        fprintf(stderr, "%s could not write x509 cert to %s", __func__, fname);
    }
cleanup:
    if (f)
        fclose(f);
    if (cert)
        X509_free(cert);
out:
    return ret;
}
int write_cert ( const struct key * key_in , const char * cn , const char * fname ) { X509 * cert = NULL ; FILE * f = NULL ; int ret = 0 ; cert = gen_signed_cert ( key_in -> pkey , cn ) ; if ( ! cert ) { fprintf ( stderr , " " , __func__ ) ; ret = 0 ; goto out ; } f = fopen ( fname , " " ) ; if ( ! f ) { fprintf ( stderr , " " , __func__ , fname , errno ) ; ret = 0 ; goto cleanup ; } ret = PEM_write_X509 ( f , cert ) ; if ( ! ret ) { fprintf ( stderr , " " , __func__ , fname ) ; } cleanup : if ( f ) fclose ( f ) ; if ( cert ) X509_free ( cert ) ; out : return ret ; }
write_x509_cert() - Write an X509 cert to a file
 @cert: The certificate to write
 @fname: A string containing the name of the file to write into
write_x509_cert () - Write an X509 cert to a file @cert : The certificate to write @fname : A string containing the name of the file to write into