From 3c8abbf103555809d110c21f89de60869a4a6bea Mon Sep 17 00:00:00 2001 From: Michal Rokos Date: Tue, 5 Mar 2002 15:05:29 +0000 Subject: * WARNING! All to_str methods are not used any longer (use to_text instead) * made an aliases to_pem as to_s * more relaxed params checking - everywhere where string was needed it is OK that obj implements to_s method --- ossl_x509.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'ossl_x509.c') diff --git a/ossl_x509.c b/ossl_x509.c index e2034e1..af97234 100644 --- a/ossl_x509.c +++ b/ossl_x509.c @@ -140,17 +140,13 @@ ossl_x509_initialize(int argc, VALUE *argv, VALUE self) case T_NIL: x509 = X509_new(); break; - - case T_STRING: + default: + buffer = rb_String(buffer); if (!(in = BIO_new_mem_buf(RSTRING(buffer)->ptr, RSTRING(buffer)->len))) { OSSL_Raise(eX509CertificateError, ""); } x509 = PEM_read_bio_X509(in, NULL, NULL, NULL); BIO_free(in); - break; - - default: - rb_raise(rb_eTypeError, "unsupported type"); } if (!x509) @@ -210,7 +206,7 @@ ossl_x509_to_pem(VALUE self) } static VALUE -ossl_x509_to_str(VALUE self) +ossl_x509_to_text(VALUE self) { ossl_x509 *x509p = NULL; BIO *out = NULL; @@ -682,7 +678,8 @@ Init_ossl_x509(VALUE module) rb_define_method(cX509Certificate, "initialize", ossl_x509_initialize, -1); rb_define_method(cX509Certificate, "to_der", ossl_x509_to_der, 0); rb_define_method(cX509Certificate, "to_pem", ossl_x509_to_pem, 0); - rb_define_method(cX509Certificate, "to_str", ossl_x509_to_str, 0); + rb_define_alias(cX509Certificate, "to_s", "to_pem"); + rb_define_method(cX509Certificate, "to_text", ossl_x509_to_text, 0); rb_define_method(cX509Certificate, "version", ossl_x509_get_version, 0); rb_define_method(cX509Certificate, "version=", ossl_x509_set_version, 1); rb_define_method(cX509Certificate, "serial", ossl_x509_get_serial, 0); -- cgit v1.2.3