xml-kit 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdf597e61009dcd52e6c3be804169a1ca885f8ae74f03831f5b5257681166309
4
- data.tar.gz: d28d3d23d4cef12e86c699b39cd353c34608a1a934c65bdd56dac5ebc77c4d94
3
+ metadata.gz: 763d302952d50ea00aad995aed62996708732c266e32e3fafeea3cc4e9db6c05
4
+ data.tar.gz: 537a44ee7c79ba0edd4a32d850320845395aa4d1499b2c7138891d20dfe71970
5
5
  SHA512:
6
- metadata.gz: cc040ed426706033521a32f1bd68d5d52c6dee40c5f0424cd6089e14c0e72c0cd7f04db54b07961358007346e7decd260dd06d09de8e8499fef29953692112d5
7
- data.tar.gz: cfea279707e9244bd1c1cba4a214ccfc75005d85e66f3edfd22ab4343968001c5541056aef260c5500194bc5786adc2d1545ff1476485648fd0da3d81092dc17
6
+ metadata.gz: '01894af70c7d56882b04968eec80650acc3263e98633a8a04f4727d434b860197d6d39bf266f1750b13f8b66aebdc94c4bd3e917244c9def16f55f73e1d296d9'
7
+ data.tar.gz: ecf023714655c4293064ce8656aa6e65e115b264be25f2d240ddfe5e37f3a2e532fa13f2137d99c6473350b3a98325491e307e42f52a10cf47c1eb0495e6646c
@@ -90,24 +90,43 @@ module Xml
90
90
  KeyPair.new(x509.to_pem, private_key.to_s, passphrase, use)
91
91
  end
92
92
 
93
- def self.to_x509(value)
94
- value = Base64.decode64(strip(value)) if base64?(value)
95
- return value if value.is_a?(OpenSSL::X509::Certificate)
96
- OpenSSL::X509::Certificate.new(value)
93
+ def expired?(time = Time.now)
94
+ x509.not_after <= time
97
95
  end
98
96
 
99
- def self.base64?(value)
100
- return unless value.is_a?(String)
97
+ def active?(time = Time.now)
98
+ x509.not_before <= time && !expired?(time)
99
+ end
100
+
101
+ def not_after
102
+ x509.not_after
103
+ end
101
104
 
102
- sanitized_value = strip(value)
103
- !!sanitized_value.match(BASE64_FORMAT)
105
+ def not_before
106
+ x509.not_before
104
107
  end
105
108
 
106
- def self.strip(value)
107
- value.
108
- gsub(BEGIN_CERT, '').
109
- gsub(END_CERT, '').
110
- gsub(/[\r\n]|\\r|\\n|\s/, "")
109
+ class << self
110
+ def to_x509(value)
111
+ return value if value.is_a?(OpenSSL::X509::Certificate)
112
+
113
+ value = Base64.decode64(strip(value)) if base64?(value)
114
+ OpenSSL::X509::Certificate.new(value)
115
+ end
116
+
117
+ def base64?(value)
118
+ return unless value.is_a?(String)
119
+
120
+ sanitized_value = strip(value)
121
+ !!sanitized_value.match(BASE64_FORMAT)
122
+ end
123
+
124
+ def strip(value)
125
+ value.
126
+ gsub(BEGIN_CERT, '').
127
+ gsub(END_CERT, '').
128
+ gsub(/[\r\n]|\\r|\\n|\s/, "")
129
+ end
111
130
  end
112
131
  end
113
132
  end
@@ -1,7 +1,7 @@
1
1
  module Xml
2
2
  module Kit
3
3
  class SelfSignedCertificate
4
- SUBJECT="/C=CA/ST=Alberta/L=Calgary/O=XmlKit/OU=XmlKit/CN=XmlKit"
4
+ SUBJECT="/C=CA/ST=AB/L=Calgary/O=XmlKit/OU=XmlKit/CN=XmlKit"
5
5
 
6
6
  def create(algorithm: 'AES-256-CBC', passphrase: nil, key_pair: OpenSSL::PKey::RSA.new(2048))
7
7
  certificate = certificate_for(key_pair.public_key)
@@ -1,5 +1,5 @@
1
1
  module Xml
2
2
  module Kit
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan