2003-07-23 20:12:24 +04:00
|
|
|
/*
|
|
|
|
* 'OpenSSL for Ruby' project
|
|
|
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
/*
|
2015-04-20 06:55:09 +03:00
|
|
|
* This program is licensed under the same licence as Ruby.
|
2003-07-23 20:12:24 +04:00
|
|
|
* (See the file 'LICENCE'.)
|
|
|
|
*/
|
|
|
|
#include "ossl.h"
|
|
|
|
|
2015-05-29 08:55:02 +03:00
|
|
|
#define NewX509Req(klass) \
|
|
|
|
TypedData_Wrap_Struct((klass), &ossl_x509req_type, 0)
|
|
|
|
#define SetX509Req(obj, req) do { \
|
2011-03-18 14:45:43 +03:00
|
|
|
if (!(req)) { \
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
|
|
|
|
} \
|
2015-05-29 08:55:02 +03:00
|
|
|
RTYPEDDATA_DATA(obj) = (req); \
|
2003-07-23 20:12:24 +04:00
|
|
|
} while (0)
|
|
|
|
#define GetX509Req(obj, req) do { \
|
2014-12-13 02:59:28 +03:00
|
|
|
TypedData_Get_Struct((obj), X509_REQ, &ossl_x509req_type, (req)); \
|
2011-03-18 14:45:43 +03:00
|
|
|
if (!(req)) { \
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Classes
|
|
|
|
*/
|
|
|
|
VALUE cX509Req;
|
|
|
|
VALUE eX509ReqError;
|
|
|
|
|
2014-12-13 02:59:28 +03:00
|
|
|
static void
|
|
|
|
ossl_x509req_free(void *ptr)
|
|
|
|
{
|
|
|
|
X509_REQ_free(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const rb_data_type_t ossl_x509req_type = {
|
|
|
|
"OpenSSL/X509/REQ",
|
|
|
|
{
|
|
|
|
0, ossl_x509req_free,
|
|
|
|
},
|
|
|
|
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
|
|
|
};
|
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
/*
|
|
|
|
* Public functions
|
|
|
|
*/
|
2003-11-01 12:24:55 +03:00
|
|
|
X509_REQ *
|
|
|
|
GetX509ReqPtr(VALUE obj)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
|
2017-09-03 15:35:27 +03:00
|
|
|
GetX509Req(obj, req);
|
2003-11-01 12:24:55 +03:00
|
|
|
|
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
/*
|
|
|
|
* Private functions
|
|
|
|
*/
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_alloc(VALUE klass)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
VALUE obj;
|
|
|
|
|
2015-05-29 08:55:02 +03:00
|
|
|
obj = NewX509Req(klass);
|
2003-07-23 20:12:24 +04:00
|
|
|
if (!(req = X509_REQ_new())) {
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
2015-05-29 08:55:02 +03:00
|
|
|
SetX509Req(obj, req);
|
2003-07-23 20:12:24 +04:00
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
|
{
|
|
|
|
BIO *in;
|
2021-05-19 11:58:18 +03:00
|
|
|
X509_REQ *req, *req_orig = RTYPEDDATA_DATA(self);
|
2003-09-17 13:05:02 +04:00
|
|
|
VALUE arg;
|
2003-07-23 20:12:24 +04:00
|
|
|
|
2021-05-19 11:58:18 +03:00
|
|
|
rb_check_frozen(self);
|
2003-09-17 13:05:02 +04:00
|
|
|
if (rb_scan_args(argc, argv, "01", &arg) == 0) {
|
2003-07-23 20:12:24 +04:00
|
|
|
return self;
|
|
|
|
}
|
2003-09-17 13:05:02 +04:00
|
|
|
arg = ossl_to_der_if_possible(arg);
|
2017-08-10 12:23:45 +03:00
|
|
|
in = ossl_obj2bio(&arg);
|
2021-05-19 11:58:18 +03:00
|
|
|
req = d2i_X509_REQ_bio(in, NULL);
|
2003-07-23 20:12:24 +04:00
|
|
|
if (!req) {
|
2021-05-19 11:58:18 +03:00
|
|
|
OSSL_BIO_reset(in);
|
|
|
|
req = PEM_read_bio_X509_REQ(in, NULL, NULL, NULL);
|
2003-07-23 20:12:24 +04:00
|
|
|
}
|
|
|
|
BIO_free(in);
|
2021-05-19 11:58:18 +03:00
|
|
|
if (!req)
|
|
|
|
ossl_raise(eX509ReqError, "PEM_read_bio_X509_REQ");
|
|
|
|
|
|
|
|
RTYPEDDATA_DATA(self) = req;
|
|
|
|
X509_REQ_free(req_orig);
|
2003-07-23 20:12:24 +04:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
ossl_x509req_copy(VALUE self, VALUE other)
|
|
|
|
{
|
|
|
|
X509_REQ *a, *b, *req;
|
2010-04-22 12:21:01 +04:00
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
rb_check_frozen(self);
|
|
|
|
if (self == other) return self;
|
|
|
|
GetX509Req(self, a);
|
2017-09-03 15:35:27 +03:00
|
|
|
GetX509Req(other, b);
|
2003-07-23 20:12:24 +04:00
|
|
|
if (!(req = X509_REQ_dup(b))) {
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
X509_REQ_free(a);
|
|
|
|
DATA_PTR(self) = req;
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_to_pem(VALUE self)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
BIO *out;
|
2010-04-22 12:21:01 +04:00
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
GetX509Req(self, req);
|
|
|
|
if (!(out = BIO_new(BIO_s_mem()))) {
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
if (!PEM_write_bio_X509_REQ(out, req)) {
|
|
|
|
BIO_free(out);
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
|
2016-11-30 17:41:46 +03:00
|
|
|
return ossl_membio2str(out);
|
2003-07-23 20:12:24 +04:00
|
|
|
}
|
|
|
|
|
2003-11-13 10:48:20 +03:00
|
|
|
static VALUE
|
|
|
|
ossl_x509req_to_der(VALUE self)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
VALUE str;
|
|
|
|
long len;
|
|
|
|
unsigned char *p;
|
|
|
|
|
|
|
|
GetX509Req(self, req);
|
|
|
|
if ((len = i2d_X509_REQ(req, NULL)) <= 0)
|
2011-06-11 14:39:47 +04:00
|
|
|
ossl_raise(eX509ReqError, NULL);
|
2003-11-13 10:48:20 +03:00
|
|
|
str = rb_str_new(0, len);
|
2008-07-22 19:34:23 +04:00
|
|
|
p = (unsigned char *)RSTRING_PTR(str);
|
2003-11-13 10:48:20 +03:00
|
|
|
if (i2d_X509_REQ(req, &p) <= 0)
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
ossl_str_adjust(str, p);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_to_text(VALUE self)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
BIO *out;
|
|
|
|
|
|
|
|
GetX509Req(self, req);
|
|
|
|
if (!(out = BIO_new(BIO_s_mem()))) {
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
if (!X509_REQ_print(out, req)) {
|
|
|
|
BIO_free(out);
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
|
2016-11-30 17:41:46 +03:00
|
|
|
return ossl_membio2str(out);
|
2003-07-23 20:12:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* Makes X509 from X509_REQuest
|
|
|
|
*/
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_to_x509(VALUE self, VALUE days, VALUE key)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
X509 *x509;
|
2010-04-22 12:21:01 +04:00
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
GetX509Req(self, req);
|
|
|
|
...
|
|
|
|
if (!(x509 = X509_REQ_to_X509(req, d, pkey))) {
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ossl_x509_new(x509);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_get_version(VALUE self)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
long version;
|
|
|
|
|
|
|
|
GetX509Req(self, req);
|
|
|
|
version = X509_REQ_get_version(req);
|
|
|
|
|
2016-08-29 08:47:09 +03:00
|
|
|
return LONG2NUM(version);
|
2003-07-23 20:12:24 +04:00
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_set_version(VALUE self, VALUE version)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
long ver;
|
|
|
|
|
2016-08-29 08:47:09 +03:00
|
|
|
if ((ver = NUM2LONG(version)) < 0) {
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_raise(eX509ReqError, "version must be >= 0!");
|
|
|
|
}
|
2004-12-15 09:35:55 +03:00
|
|
|
GetX509Req(self, req);
|
2003-07-23 20:12:24 +04:00
|
|
|
if (!X509_REQ_set_version(req, ver)) {
|
2016-08-29 08:47:09 +03:00
|
|
|
ossl_raise(eX509ReqError, "X509_REQ_set_version");
|
2003-07-23 20:12:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_get_subject(VALUE self)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
X509_NAME *name;
|
|
|
|
|
|
|
|
GetX509Req(self, req);
|
|
|
|
if (!(name = X509_REQ_get_subject_name(req))) { /* NO DUP - don't free */
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ossl_x509name_new(name);
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_set_subject(VALUE self, VALUE subject)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
2010-04-22 12:21:01 +04:00
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
GetX509Req(self, req);
|
|
|
|
/* DUPs name */
|
|
|
|
if (!X509_REQ_set_subject_name(req, GetX509NamePtr(subject))) {
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return subject;
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_get_signature_algorithm(VALUE self)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
2016-08-29 08:47:09 +03:00
|
|
|
const X509_ALGOR *alg;
|
2003-07-23 20:12:24 +04:00
|
|
|
BIO *out;
|
|
|
|
|
|
|
|
GetX509Req(self, req);
|
2010-04-22 12:21:01 +04:00
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
if (!(out = BIO_new(BIO_s_mem()))) {
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
2016-08-29 08:47:09 +03:00
|
|
|
X509_REQ_get0_signature(req, NULL, &alg);
|
2016-06-05 18:35:12 +03:00
|
|
|
if (!i2a_ASN1_OBJECT(out, alg->algorithm)) {
|
2003-07-23 20:12:24 +04:00
|
|
|
BIO_free(out);
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
2016-11-30 17:41:46 +03:00
|
|
|
|
|
|
|
return ossl_membio2str(out);
|
2003-07-23 20:12:24 +04:00
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_get_public_key(VALUE self)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
EVP_PKEY *pkey;
|
|
|
|
|
|
|
|
GetX509Req(self, req);
|
|
|
|
if (!(pkey = X509_REQ_get_pubkey(req))) { /* adds reference */
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ossl_pkey_new(pkey); /* NO DUP - OK */
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_set_public_key(VALUE self, VALUE key)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
EVP_PKEY *pkey;
|
|
|
|
|
|
|
|
GetX509Req(self, req);
|
2017-11-25 17:12:08 +03:00
|
|
|
pkey = GetPKeyPtr(key);
|
|
|
|
ossl_pkey_check_public_key(pkey);
|
|
|
|
if (!X509_REQ_set_pubkey(req, pkey))
|
|
|
|
ossl_raise(eX509ReqError, "X509_REQ_set_pubkey");
|
2003-07-23 20:12:24 +04:00
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_sign(VALUE self, VALUE key, VALUE digest)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
EVP_PKEY *pkey;
|
|
|
|
const EVP_MD *md;
|
|
|
|
|
|
|
|
GetX509Req(self, req);
|
|
|
|
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
|
2017-09-03 15:35:27 +03:00
|
|
|
md = ossl_evp_get_digestbyname(digest);
|
2003-07-23 20:12:24 +04:00
|
|
|
if (!X509_REQ_sign(req, pkey, md)) {
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Checks that cert signature is made with PRIVversion of this PUBLIC 'key'
|
|
|
|
*/
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_verify(VALUE self, VALUE key)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
EVP_PKEY *pkey;
|
|
|
|
|
|
|
|
GetX509Req(self, req);
|
2017-11-25 17:12:08 +03:00
|
|
|
pkey = GetPKeyPtr(key);
|
|
|
|
ossl_pkey_check_public_key(pkey);
|
2016-05-18 07:07:47 +03:00
|
|
|
switch (X509_REQ_verify(req, pkey)) {
|
|
|
|
case 1:
|
2003-07-23 20:12:24 +04:00
|
|
|
return Qtrue;
|
2016-05-18 07:07:47 +03:00
|
|
|
case 0:
|
|
|
|
ossl_clear_error();
|
|
|
|
return Qfalse;
|
|
|
|
default:
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
2003-07-23 20:12:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_get_attributes(VALUE self)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
int count, i;
|
|
|
|
X509_ATTRIBUTE *attr;
|
|
|
|
VALUE ary;
|
2010-04-22 12:21:01 +04:00
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
GetX509Req(self, req);
|
|
|
|
|
|
|
|
count = X509_REQ_get_attr_count(req);
|
|
|
|
if (count < 0) {
|
|
|
|
OSSL_Debug("count < 0???");
|
|
|
|
return rb_ary_new();
|
|
|
|
}
|
|
|
|
ary = rb_ary_new2(count);
|
|
|
|
for (i=0; i<count; i++) {
|
|
|
|
attr = X509_REQ_get_attr(req, i);
|
|
|
|
rb_ary_push(ary, ossl_x509attr_new(attr));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_set_attributes(VALUE self, VALUE ary)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
X509_ATTRIBUTE *attr;
|
2015-11-04 10:18:01 +03:00
|
|
|
long i;
|
2005-08-23 00:47:55 +04:00
|
|
|
VALUE item;
|
2003-07-23 20:12:24 +04:00
|
|
|
|
|
|
|
Check_Type(ary, T_ARRAY);
|
2006-09-02 18:42:08 +04:00
|
|
|
for (i=0;i<RARRAY_LEN(ary); i++) {
|
2015-11-05 04:09:17 +03:00
|
|
|
OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Attr);
|
2003-07-23 20:12:24 +04:00
|
|
|
}
|
2004-12-15 09:35:55 +03:00
|
|
|
GetX509Req(self, req);
|
2016-06-05 18:35:12 +03:00
|
|
|
while ((attr = X509_REQ_delete_attr(req, 0)))
|
|
|
|
X509_ATTRIBUTE_free(attr);
|
2006-09-02 18:42:08 +04:00
|
|
|
for (i=0;i<RARRAY_LEN(ary); i++) {
|
2015-11-05 04:09:17 +03:00
|
|
|
item = RARRAY_AREF(ary, i);
|
2016-08-29 08:47:09 +03:00
|
|
|
attr = GetX509AttrPtr(item);
|
2003-07-23 20:12:24 +04:00
|
|
|
if (!X509_REQ_add1_attr(req, attr)) {
|
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2010-04-22 12:04:13 +04:00
|
|
|
static VALUE
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_x509req_add_attribute(VALUE self, VALUE attr)
|
|
|
|
{
|
|
|
|
X509_REQ *req;
|
|
|
|
|
|
|
|
GetX509Req(self, req);
|
2016-08-29 08:47:09 +03:00
|
|
|
if (!X509_REQ_add1_attr(req, GetX509AttrPtr(attr))) {
|
2003-07-23 20:12:24 +04:00
|
|
|
ossl_raise(eX509ReqError, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return attr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* X509_REQUEST init
|
|
|
|
*/
|
2010-04-22 12:04:13 +04:00
|
|
|
void
|
2014-09-30 09:25:32 +04:00
|
|
|
Init_ossl_x509req(void)
|
2003-07-23 20:12:24 +04:00
|
|
|
{
|
2016-08-29 08:47:09 +03:00
|
|
|
#if 0
|
|
|
|
mOSSL = rb_define_module("OpenSSL");
|
|
|
|
eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
|
|
|
|
mX509 = rb_define_module_under(mOSSL, "X509");
|
|
|
|
#endif
|
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
eX509ReqError = rb_define_class_under(mX509, "RequestError", eOSSLError);
|
2010-04-22 12:21:01 +04:00
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
cX509Req = rb_define_class_under(mX509, "Request", rb_cObject);
|
2010-04-22 12:21:01 +04:00
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
rb_define_alloc_func(cX509Req, ossl_x509req_alloc);
|
|
|
|
rb_define_method(cX509Req, "initialize", ossl_x509req_initialize, -1);
|
2017-09-03 15:35:27 +03:00
|
|
|
rb_define_method(cX509Req, "initialize_copy", ossl_x509req_copy, 1);
|
2010-04-22 12:21:01 +04:00
|
|
|
|
2003-07-23 20:12:24 +04:00
|
|
|
rb_define_method(cX509Req, "to_pem", ossl_x509req_to_pem, 0);
|
2003-11-13 10:48:20 +03:00
|
|
|
rb_define_method(cX509Req, "to_der", ossl_x509req_to_der, 0);
|
2003-07-23 20:12:24 +04:00
|
|
|
rb_define_alias(cX509Req, "to_s", "to_pem");
|
|
|
|
rb_define_method(cX509Req, "to_text", ossl_x509req_to_text, 0);
|
|
|
|
rb_define_method(cX509Req, "version", ossl_x509req_get_version, 0);
|
|
|
|
rb_define_method(cX509Req, "version=", ossl_x509req_set_version, 1);
|
|
|
|
rb_define_method(cX509Req, "subject", ossl_x509req_get_subject, 0);
|
|
|
|
rb_define_method(cX509Req, "subject=", ossl_x509req_set_subject, 1);
|
|
|
|
rb_define_method(cX509Req, "signature_algorithm", ossl_x509req_get_signature_algorithm, 0);
|
|
|
|
rb_define_method(cX509Req, "public_key", ossl_x509req_get_public_key, 0);
|
|
|
|
rb_define_method(cX509Req, "public_key=", ossl_x509req_set_public_key, 1);
|
|
|
|
rb_define_method(cX509Req, "sign", ossl_x509req_sign, 2);
|
|
|
|
rb_define_method(cX509Req, "verify", ossl_x509req_verify, 1);
|
|
|
|
rb_define_method(cX509Req, "attributes", ossl_x509req_get_attributes, 0);
|
|
|
|
rb_define_method(cX509Req, "attributes=", ossl_x509req_set_attributes, 1);
|
|
|
|
rb_define_method(cX509Req, "add_attribute", ossl_x509req_add_attribute, 1);
|
|
|
|
}
|