Ruby
2.1.3p242(2014-09-19revision47630)
Main Page
Modules
Data Structures
Files
File List
Globals
ext
openssl
ossl_config.c
Go to the documentation of this file.
1
/*
2
* $Id: ossl_config.c 43667 2013-11-13 09:34:08Z zzak $
3
* 'OpenSSL for Ruby' project
4
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
* All rights reserved.
6
*/
7
/*
8
* This program is licenced under the same licence as Ruby.
9
* (See the file 'LICENCE'.)
10
*/
11
#include "
ossl.h
"
12
13
14
/*
15
* Classes
16
*/
17
VALUE
cConfig
;
18
/* Document-class: OpenSSL::ConfigError
19
*
20
* General error for openssl library configuration files. Including formating,
21
* parsing errors, etc.
22
*/
23
VALUE
eConfigError
;
24
25
/*
26
* Public
27
*/
28
29
/*
30
* GetConfigPtr is a public C-level function for getting OpenSSL CONF struct
31
* from an OpenSSL::Config(eConfig) instance. We decided to implement
32
* OpenSSL::Config in Ruby level but we need to pass native CONF struct for
33
* some OpenSSL features such as X509V3_EXT_*.
34
*/
35
CONF *
36
GetConfigPtr
(
VALUE
obj)
37
{
38
CONF *conf;
39
VALUE
str;
40
BIO *bio;
41
long
eline = -1;
42
43
OSSL_Check_Kind
(obj,
cConfig
);
44
str =
rb_funcall
(obj,
rb_intern
(
"to_s"
), 0);
45
bio =
ossl_obj2bio
(str);
46
conf = NCONF_new(
NULL
);
47
if
(!conf){
48
BIO_free(bio);
49
ossl_raise
(
eConfigError
,
NULL
);
50
}
51
if
(!NCONF_load_bio(conf, bio, &eline)){
52
BIO_free(bio);
53
NCONF_free(conf);
54
if
(eline <= 0)
ossl_raise
(
eConfigError
,
"wrong config format"
);
55
else
ossl_raise
(
eConfigError
,
"error in line %d"
, eline);
56
ossl_raise
(
eConfigError
,
NULL
);
57
}
58
BIO_free(bio);
59
60
return
conf;
61
}
62
63
/* Document-const: DEFAULT_CONFIG_FILE
64
*
65
* The default system configuration file for openssl
66
*/
67
68
/*
69
* INIT
70
*/
71
void
72
Init_ossl_config
()
73
{
74
char
*default_config_file;
75
eConfigError
=
rb_define_class_under
(
mOSSL
,
"ConfigError"
,
eOSSLError
);
76
cConfig
=
rb_define_class_under
(
mOSSL
,
"Config"
,
rb_cObject
);
77
78
default_config_file =
CONF_get1_default_config_file
();
79
rb_define_const
(
cConfig
,
"DEFAULT_CONFIG_FILE"
,
80
rb_str_new2
(default_config_file));
81
OPENSSL_free(default_config_file);
82
/* methods are defined by openssl/config.rb */
83
}
84
Generated on Mon Sep 22 2014 11:05:24 for Ruby by
1.8.2