diff options
author | GOTOU Yuuzou <gotoyuzo@notwork.org> | 2001-11-16 15:36:38 +0000 |
---|---|---|
committer | GOTOU Yuuzou <gotoyuzo@notwork.org> | 2001-11-16 15:36:38 +0000 |
commit | 7aef9ad51ff25208bf1a4a60d1371a781ecf3dac (patch) | |
tree | 2122c82076828441be29140a1e079dc3a0a3c250 /ossl_x509.c | |
parent | 3d032c89b753d125cf383cb6a1bef6b472b0a981 (diff) | |
download | ruby-openssl-history-7aef9ad51ff25208bf1a4a60d1371a781ecf3dac.tar.gz |
for compatibility with old SSLSocket
Diffstat (limited to 'ossl_x509.c')
-rw-r--r-- | ossl_x509.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ossl_x509.c b/ossl_x509.c index 59cd2b6..739455e 100644 --- a/ossl_x509.c +++ b/ossl_x509.c @@ -56,6 +56,26 @@ VALUE ossl_x509_new2(X509 *x509) return obj; } +VALUE ossl_x509_new_from_file(VALUE v) +{ + char *path; + FILE *fp; + X509 *cert; + ossl_x509 *x509p = NULL; + VALUE obj; + + MakeX509(obj, x509p); + path = RSTRING(v)->ptr; + if((fp = fopen(path, "r")) == NULL) + rb_raise(eX509CertificateError, "%s", strerror(errno)); + cert = PEM_read_X509(fp, NULL, NULL, NULL); + fclose(fp); + if(!cert) rb_raise(eX509CertificateError, "%s", ossl_error()); + x509p->x509 = cert; + + return obj; +} + X509 *ossl_x509_get_X509(VALUE self) { ossl_x509 *x509p = NULL; |