X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=apps%2Fca.c;h=65209eeee3f7d01da328078198bba2d38fe44d34;hp=5ce0dc202b9df8bb1b91860d4d94cd160b88932d;hb=e09632f986c5bcdedd8454dd646705ef54724c78;hpb=95dc05bc6d0dfe0f3f3681f5e27afbc3f7a35eea diff --git a/apps/ca.c b/apps/ca.c index 5ce0dc202b..65209eeee3 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -64,26 +64,41 @@ #include #include #include "apps.h" -#include "conf.h" -#include "bio.h" -#include "err.h" -#include "bn.h" -#include "txt_db.h" -#include "evp.h" -#include "x509.h" -#include "x509v3.h" -#include "objects.h" -#include "pem.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef W_OK -#include +# ifdef VMS +# if defined(__DECC) +# include +# else +# include +# endif +# else +# include +# endif +#endif + +#ifndef W_OK +# define F_OK 0 +# define X_OK 1 +# define W_OK 2 +# define R_OK 4 #endif #undef PROG #define PROG ca_main #define BASE_SECTION "ca" -#define CONFIG_FILE "lib/openssl.cnf" +#define CONFIG_FILE "openssl.cnf" #define ENV_DEFAULT_CA "default_ca" @@ -156,7 +171,6 @@ extern int EF_PROTECT_BELOW; extern int EF_ALIGNMENT; #endif -#ifndef NOPROTO static int add_oid_section(LHASH *conf); static void lookup_fail(char *name,char *tag); static int MS_CALLBACK key_callback(char *buf,int len,int verify); @@ -187,27 +201,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst, LHASH *conf); static int do_revoke(X509 *x509, TXT_DB *db); static int check_time_format(char *str); -#else -static int add_oid_section(); -static void lookup_fail(); -static int MS_CALLBACK key_callback(); -static unsigned long index_serial_hash(); -static int index_serial_cmp(); -static unsigned long index_name_hash(); -static int index_name_qual(); -static int index_name_cmp(); -static int fix_data(); -static BIGNUM *load_serial(); -static int save_serial(); -static int certify(); -static int certify_cert(); -static int certify_spkac(); -static void write_new_certificate(); -static int do_body(); -static int do_revoke(); -static int check_time_format(); -#endif - static LHASH *conf; static char *key=NULL; static char *section=NULL; @@ -412,12 +405,19 @@ bad: ERR_load_crypto_strings(); /*****************************************************************/ + if (configfile == NULL) configfile = getenv("OPENSSL_CONF"); + if (configfile == NULL) configfile = getenv("SSLEAY_CONF"); if (configfile == NULL) { /* We will just use 'buf[0]' as a temporary buffer. */ +#ifdef VMS + strncpy(buf[0],X509_get_default_cert_area(), + sizeof(buf[0])-1-sizeof(CONFIG_FILE)); +#else strncpy(buf[0],X509_get_default_cert_area(), sizeof(buf[0])-2-sizeof(CONFIG_FILE)); strcat(buf[0],"/"); +#endif strcat(buf[0],CONFIG_FILE); configfile=buf[0]; } @@ -557,7 +557,12 @@ bad: BIO_printf(bio_err,"there needs to be defined a directory for new certificate to be placed in\n"); goto err; } +#ifdef VMS + /* For technical reasons, VMS misbehaves with X_OK */ + if (access(outdir,R_OK|W_OK) != 0) +#else if (access(outdir,R_OK|W_OK|X_OK) != 0) +#endif { BIO_printf(bio_err,"I am unable to acces the %s directory\n",outdir); perror(outdir); @@ -875,12 +880,23 @@ bad: BIO_printf(bio_err,"Write out database with %d new entries\n",sk_num(cert_sk)); strncpy(buf[0],serialfile,BSIZE-4); + +#ifdef VMS + strcat(buf[0],"-new"); +#else strcat(buf[0],".new"); +#endif if (!save_serial(buf[0],serial)) goto err; strncpy(buf[1],dbfile,BSIZE-4); + +#ifdef VMS + strcat(buf[1],"-new"); +#else strcat(buf[1],".new"); +#endif + if (BIO_write_filename(out,buf[1]) <= 0) { perror(dbfile); @@ -904,7 +920,11 @@ bad: p=(char *)x->cert_info->serialNumber->data; strncpy(buf[2],outdir,BSIZE-(j*2)-6); + +#ifndef VMS strcat(buf[2],"/"); +#endif + n=(unsigned char *)&(buf[2][strlen(buf[2])]); if (j > 0) { @@ -937,7 +957,13 @@ bad: { /* Rename the database and the serial file */ strncpy(buf[2],serialfile,BSIZE-4); + +#ifdef VMS + strcat(buf[2],"-old"); +#else strcat(buf[2],".old"); +#endif + BIO_free(in); BIO_free(out); in=NULL; @@ -959,7 +985,13 @@ bad: } strncpy(buf[2],dbfile,BSIZE-4); + +#ifdef VMS + strcat(buf[2],"-old"); +#else strcat(buf[2],".old"); +#endif + if (rename(dbfile,buf[2]) < 0) { BIO_printf(bio_err,"unabel to rename %s to %s\n", @@ -1743,7 +1775,8 @@ again2: /* Free the current entries if any, there should not * be any I belive */ if (ci->extensions != NULL) - sk_pop_free(ci->extensions,X509_EXTENSION_free); + sk_X509_EXTENSION_pop_free(ci->extensions, + X509_EXTENSION_free); ci->extensions = NULL;