diff options
author | Bart de Water <bartdewater@gmail.com> | 2019-10-26 13:34:04 -0400 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2019-10-29 22:14:01 +1300 |
commit | feb6d2c5278bdd66cf0cfdbf828c6ef8effa3d70 (patch) | |
tree | 9fef8398774de584de517812ed9e23bc964c8b14 /lib/openssl | |
parent | 308fb199811d085c771e421eb304b4aedf501262 (diff) | |
download | ruby-openssl-feb6d2c5278bdd66cf0cfdbf828c6ef8effa3d70.tar.gz |
Add Marshal support to X509 objects
This allows for example to use Rails' cache to store these objects. Without this patch you'd get errors like "TypeError (no _dump_data is defined for class OpenSSL::X509::Certificate)"
Note that the X509::Revoked class doesn't need the newly introduced modules as the DER output of X509::CRL already includes these.
Diffstat (limited to 'lib/openssl')
-rw-r--r-- | lib/openssl/x509.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/openssl/x509.rb b/lib/openssl/x509.rb index 4f3a4337..426f99d2 100644 --- a/lib/openssl/x509.rb +++ b/lib/openssl/x509.rb @@ -14,6 +14,22 @@ module OpenSSL module X509 + module Marshal + def self.included(base) + base.extend(ClassMethods) + end + + module ClassMethods + def _load(string) + new(string) + end + end + + def _dump(_level) + to_der + end + end + class ExtensionFactory def create_extension(*arg) if arg.size > 1 @@ -41,6 +57,8 @@ module OpenSSL end class Extension + include Marshal + def ==(other) return false unless Extension === other to_der == other.to_der @@ -116,6 +134,8 @@ module OpenSSL end class Name + include Marshal + module RFC2253DN Special = ',=+<>#;' HexChar = /[0-9a-fA-F]/ @@ -219,6 +239,8 @@ module OpenSSL end class Attribute + include Marshal + def ==(other) return false unless Attribute === other to_der == other.to_der @@ -232,6 +254,7 @@ module OpenSSL end class Certificate + include Marshal include Extension::SubjectKeyIdentifier include Extension::AuthorityKeyIdentifier @@ -248,6 +271,7 @@ module OpenSSL end class CRL + include Marshal include Extension::AuthorityKeyIdentifier def ==(other) @@ -264,6 +288,8 @@ module OpenSSL end class Request + include Marshal + def ==(other) return false unless Request === other to_der == other.to_der |