00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "ossl.h"
00012
00013
00014
00015
00016
00017 VALUE cConfig;
00018 VALUE eConfigError;
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 CONF *
00031 GetConfigPtr(VALUE obj)
00032 {
00033 CONF *conf;
00034 VALUE str;
00035 BIO *bio;
00036 long eline = -1;
00037
00038 OSSL_Check_Kind(obj, cConfig);
00039 str = rb_funcall(obj, rb_intern("to_s"), 0);
00040 bio = ossl_obj2bio(str);
00041 conf = NCONF_new(NULL);
00042 if(!conf){
00043 BIO_free(bio);
00044 ossl_raise(eConfigError, NULL);
00045 }
00046 if(!NCONF_load_bio(conf, bio, &eline)){
00047 BIO_free(bio);
00048 NCONF_free(conf);
00049 if (eline <= 0) ossl_raise(eConfigError, "wrong config format");
00050 else ossl_raise(eConfigError, "error in line %d", eline);
00051 ossl_raise(eConfigError, NULL);
00052 }
00053 BIO_free(bio);
00054
00055 return conf;
00056 }
00057
00058
00059
00060
00061
00062 void
00063 Init_ossl_config()
00064 {
00065 char *default_config_file;
00066 eConfigError = rb_define_class_under(mOSSL, "ConfigError", eOSSLError);
00067 cConfig = rb_define_class_under(mOSSL, "Config", rb_cObject);
00068
00069 default_config_file = CONF_get1_default_config_file();
00070 rb_define_const(cConfig, "DEFAULT_CONFIG_FILE",
00071 rb_str_new2(default_config_file));
00072 OPENSSL_free(default_config_file);
00073
00074 }
00075