diff options
author | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 11:56:39 +0100 |
---|---|---|
committer | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 11:56:39 +0100 |
commit | 58964a492275ca9a59a0cd9c8155cb2491b4b909 (patch) | |
tree | c7b16876a5789463bbbb468ef4829c8129b3d718 /crypto/x509/by_file.c | |
parent | Import of old SSLeay release: SSLeay 0.8.1b (diff) | |
download | openssl-58964a492275ca9a59a0cd9c8155cb2491b4b909.tar.xz openssl-58964a492275ca9a59a0cd9c8155cb2491b4b909.zip |
Import of old SSLeay release: SSLeay 0.9.0b
Diffstat (limited to 'crypto/x509/by_file.c')
-rw-r--r-- | crypto/x509/by_file.c | 95 |
1 files changed, 86 insertions, 9 deletions
diff --git a/crypto/x509/by_file.c b/crypto/x509/by_file.c index 2dac28f542..09ebb9bf08 100644 --- a/crypto/x509/by_file.c +++ b/crypto/x509/by_file.c @@ -1,5 +1,5 @@ /* crypto/x509/by_file.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written @@ -68,6 +68,8 @@ #include "x509.h" #include "pem.h" +#ifndef NO_STDIO + #ifndef NOPROTO static int by_file_ctrl(X509_LOOKUP *ctx,int cmd,char *argc, long argl,char **ret); @@ -101,7 +103,7 @@ char *argp; long argl; char **ret; { - int ok=0; + int ok=0,ok2=0; char *file; switch (cmd) @@ -111,7 +113,9 @@ char **ret; { ok=X509_load_cert_file(ctx,X509_get_default_cert_file(), X509_FILETYPE_PEM); - if (!ok) + ok2=X509_load_crl_file(ctx,X509_get_default_cert_file(), + X509_FILETYPE_PEM); + if (!ok || !ok2) { X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS); } @@ -120,13 +124,18 @@ char **ret; file=(char *)Getenv(X509_get_default_cert_file_env()); ok=X509_load_cert_file(ctx,file, X509_FILETYPE_PEM); + ok2=X509_load_crl_file(ctx,file, + X509_FILETYPE_PEM); } } else + { ok=X509_load_cert_file(ctx,argp,(int)argl); + ok2=X509_load_crl_file(ctx,argp,(int)argl); + } break; } - return(ok); + return((ok && ok2)?ok:0); } int X509_load_cert_file(ctx,file,type) @@ -140,11 +149,7 @@ int type; X509 *x=NULL; if (file == NULL) return(1); -#ifndef WIN16 - in=BIO_new(BIO_s_file()); -#else - in=BIO_new(BIO_s_file_internal_w16()); -#endif + in=BIO_new(BIO_s_file_internal()); if ((in == NULL) || (BIO_read_filename(in,file) <= 0)) { @@ -203,3 +208,75 @@ err: return(ret); } +int X509_load_crl_file(ctx,file,type) +X509_LOOKUP *ctx; +char *file; +int type; + { + int ret=0; + BIO *in=NULL; + int i,count=0; + X509_CRL *x=NULL; + + if (file == NULL) return(1); + in=BIO_new(BIO_s_file_internal()); + + if ((in == NULL) || (BIO_read_filename(in,file) <= 0)) + { + X509err(X509_F_X509_LOAD_CRL_FILE,ERR_R_SYS_LIB); + goto err; + } + + if (type == X509_FILETYPE_PEM) + { + for (;;) + { + x=PEM_read_bio_X509_CRL(in,NULL,NULL); + if (x == NULL) + { + if ((ERR_GET_REASON(ERR_peek_error()) == + PEM_R_NO_START_LINE) && (count > 0)) + { + ERR_clear_error(); + break; + } + else + { + X509err(X509_F_X509_LOAD_CRL_FILE, + ERR_R_PEM_LIB); + goto err; + } + } + i=X509_STORE_add_crl(ctx->store_ctx,x); + if (!i) goto err; + count++; + X509_CRL_free(x); + x=NULL; + } + ret=count; + } + else if (type == X509_FILETYPE_ASN1) + { + x=d2i_X509_CRL_bio(in,NULL); + if (x == NULL) + { + X509err(X509_F_X509_LOAD_CRL_FILE,ERR_R_ASN1_LIB); + goto err; + } + i=X509_STORE_add_crl(ctx->store_ctx,x); + if (!i) goto err; + ret=i; + } + else + { + X509err(X509_F_X509_LOAD_CRL_FILE,X509_R_BAD_X509_FILETYPE); + goto err; + } +err: + if (x != NULL) X509_CRL_free(x); + if (in != NULL) BIO_free(in); + return(ret); + } + +#endif /* NO_STDIO */ + |