keygen/src/ssl.c
/**
 * write_EC_private_key() - Write a puiblic and private key in PEM format
 * @ec_key: The key to be written
 * @fname: A string containing the name of the file to write into
 *
 * Return: 1 on success or 0 on failure
 */
Write a puiblic and private key in PEM format
@ec_key: The key to be written
@fname: A string containing the name of the file to write into

1 on success or 0 on failure
Write a puiblic and private key in PEM format @ec_key : The key to be written @fname : A string containing the name of the file to write into 1 on success or 0 on failure
int write_key(struct key *key_in, const char *fname)
{
    FILE *f;
    int ret;
    f = fopen(fname, "w");
    if(!f) {
        fprintf(stderr, "%s could not open %s, fopen error=%d", __func__, fname, errno);
        ret = 0;
        goto out;
    }
    ret = PEM_write_PKCS8PrivateKey(f, key_in->pkey, NULL,NULL,0,NULL,NULL);
    if (!ret) {
        fprintf(stderr, "%s could not write private key to %s", __func__, fname);
    }
    fclose(f);
out:
    return ret;
}
int write_key ( struct key * key_in , const char * fname ) { FILE * f ; int ret ; f = fopen ( fname , " " ) ; if ( ! f ) { fprintf ( stderr , " " , __func__ , fname , errno ) ; ret = 0 ; goto out ; } ret = PEM_write_PKCS8PrivateKey ( f , key_in -> pkey , NULL , NULL , 0 , NULL , NULL ) ; if ( ! ret ) { fprintf ( stderr , " " , __func__ , fname ) ; } fclose ( f ) ; out : return ret ; }
write_EC_private_key() - Write a puiblic and private key in PEM format
 @ec_key: The key to be written
 @fname: A string containing the name of the file to write into
write_EC_private_key () - Write a puiblic and private key in PEM format @ec_key : The key to be written @fname : A string containing the name of the file to write into
/* Open the file for writing */ /* Write the private key to the file */