r509 0.10.0 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.mdown +2 -2
  5. data/Rakefile +2 -3
  6. data/bin/r509 +77 -80
  7. data/bin/r509-parse +4 -4
  8. data/doc/R509.html +60 -60
  9. data/doc/R509/ASN1.html +158 -48
  10. data/doc/R509/ASN1/GeneralName.html +157 -154
  11. data/doc/R509/ASN1/GeneralNames.html +246 -237
  12. data/doc/R509/CRL.html +41 -39
  13. data/doc/R509/CRL/Administrator.html +105 -100
  14. data/doc/R509/CRL/FileReaderWriter.html +146 -98
  15. data/doc/R509/CRL/ReaderWriter.html +57 -54
  16. data/doc/R509/CRL/SQLiteReaderWriter.html +727 -0
  17. data/doc/R509/CRL/SignedList.html +83 -80
  18. data/doc/R509/CSR.html +184 -162
  19. data/doc/R509/Cert.html +271 -269
  20. data/doc/R509/Cert/Extensions.html +62 -63
  21. data/doc/R509/Cert/Extensions/AuthorityInfoAccess.html +138 -108
  22. data/doc/R509/Cert/Extensions/AuthorityKeyIdentifier.html +100 -84
  23. data/doc/R509/Cert/Extensions/BasicConstraints.html +89 -88
  24. data/doc/R509/Cert/Extensions/CRLDistributionPoints.html +87 -83
  25. data/doc/R509/Cert/Extensions/CertificatePolicies.html +78 -76
  26. data/doc/R509/Cert/Extensions/ExtendedKeyUsage.html +128 -125
  27. data/doc/R509/Cert/Extensions/GeneralNamesMixin.html +83 -78
  28. data/doc/R509/Cert/Extensions/InhibitAnyPolicy.html +69 -67
  29. data/doc/R509/Cert/Extensions/KeyUsage.html +138 -135
  30. data/doc/R509/Cert/Extensions/NameConstraints.html +82 -81
  31. data/doc/R509/Cert/Extensions/NoticeReference.html +59 -56
  32. data/doc/R509/Cert/Extensions/OCSPNoCheck.html +70 -69
  33. data/doc/R509/Cert/Extensions/PolicyConstraints.html +71 -69
  34. data/doc/R509/Cert/Extensions/PolicyInformation.html +63 -60
  35. data/doc/R509/Cert/Extensions/PolicyQualifiers.html +60 -57
  36. data/doc/R509/Cert/Extensions/SubjectAlternativeName.html +91 -87
  37. data/doc/R509/Cert/Extensions/SubjectKeyIdentifier.html +72 -71
  38. data/doc/R509/Cert/Extensions/UserNotice.html +60 -57
  39. data/doc/R509/Cert/Extensions/ValidationMixin.html +43 -40
  40. data/doc/R509/CertificateAuthority.html +39 -37
  41. data/doc/R509/CertificateAuthority/OptionsBuilder.html +58 -55
  42. data/doc/R509/CertificateAuthority/Signer.html +277 -60
  43. data/doc/R509/Config.html +40 -38
  44. data/doc/R509/Config/CAConfig.html +255 -188
  45. data/doc/R509/Config/CAConfigPool.html +64 -61
  46. data/doc/R509/Config/CertProfile.html +119 -116
  47. data/doc/R509/Config/SubjectItemPolicy.html +94 -93
  48. data/doc/R509/Engine.html +60 -56
  49. data/doc/R509/Helpers.html +99 -96
  50. data/doc/R509/MessageDigest.html +69 -68
  51. data/doc/R509/NameSanitizer.html +51 -48
  52. data/doc/R509/OCSP.html +39 -37
  53. data/doc/R509/OCSP/Request.html +39 -37
  54. data/doc/R509/OCSP/Request/Nonce.html +67 -67
  55. data/doc/R509/OCSP/Response.html +93 -90
  56. data/doc/R509/OIDMapper.html +48 -46
  57. data/doc/R509/PrivateKey.html +170 -169
  58. data/doc/R509/R509Error.html +45 -42
  59. data/doc/R509/SPKI.html +99 -89
  60. data/doc/R509/Subject.html +86 -83
  61. data/doc/R509/Validity.html +57 -57
  62. data/doc/R509/Validity/Checker.html +63 -93
  63. data/doc/R509/Validity/DefaultChecker.html +58 -55
  64. data/doc/R509/Validity/DefaultWriter.html +62 -59
  65. data/doc/R509/Validity/Status.html +77 -74
  66. data/doc/R509/Validity/Writer.html +75 -123
  67. data/doc/_index.html +37 -31
  68. data/doc/class_list.html +25 -27
  69. data/doc/css/full_list.css +32 -31
  70. data/doc/css/style.css +221 -78
  71. data/doc/file.CONTRIBUTING.html +29 -30
  72. data/doc/file.LICENSE.html +29 -30
  73. data/doc/file.README.html +31 -32
  74. data/doc/file.YAML.html +33 -34
  75. data/doc/file.r509.html +39 -48
  76. data/doc/file_list.html +39 -30
  77. data/doc/frames.html +10 -21
  78. data/doc/index.html +31 -32
  79. data/doc/js/app.js +100 -71
  80. data/doc/js/full_list.js +168 -130
  81. data/doc/method_list.html +1788 -1119
  82. data/doc/top-level-namespace.html +45 -49
  83. data/lib/r509.rb +21 -7
  84. data/lib/r509/asn1.rb +45 -32
  85. data/lib/r509/cert.rb +45 -51
  86. data/lib/r509/cert/extensions/authority_info_access.rb +49 -23
  87. data/lib/r509/cert/extensions/authority_key_identifier.rb +16 -11
  88. data/lib/r509/cert/extensions/base.rb +22 -23
  89. data/lib/r509/cert/extensions/basic_constraints.rb +11 -12
  90. data/lib/r509/cert/extensions/certificate_policies.rb +26 -26
  91. data/lib/r509/cert/extensions/crl_distribution_points.rb +5 -7
  92. data/lib/r509/cert/extensions/extended_key_usage.rb +5 -5
  93. data/lib/r509/cert/extensions/inhibit_any_policy.rb +4 -3
  94. data/lib/r509/cert/extensions/key_usage.rb +5 -5
  95. data/lib/r509/cert/extensions/name_constraints.rb +16 -16
  96. data/lib/r509/cert/extensions/ocsp_no_check.rb +3 -3
  97. data/lib/r509/cert/extensions/policy_constraints.rb +8 -8
  98. data/lib/r509/cert/extensions/subject_alternative_name.rb +5 -4
  99. data/lib/r509/cert/extensions/subject_key_identifier.rb +5 -5
  100. data/lib/r509/cert/extensions/validation_mixin.rb +11 -10
  101. data/lib/r509/certificate_authority/options_builder.rb +19 -21
  102. data/lib/r509/certificate_authority/signer.rb +26 -27
  103. data/lib/r509/config.rb +1 -0
  104. data/lib/r509/config/ca_config.rb +70 -75
  105. data/lib/r509/config/cert_profile.rb +9 -8
  106. data/lib/r509/config/subject_item_policy.rb +25 -28
  107. data/lib/r509/crl/administrator.rb +19 -20
  108. data/lib/r509/crl/reader_writer.rb +10 -8
  109. data/lib/r509/crl/signed_list.rb +4 -4
  110. data/lib/r509/crl/sqlite_reader_writer.rb +75 -0
  111. data/lib/r509/csr.rb +54 -60
  112. data/lib/r509/ec-hack.rb +3 -2
  113. data/lib/r509/engine.rb +5 -6
  114. data/lib/r509/exceptions.rb +1 -1
  115. data/lib/r509/helpers.rb +11 -14
  116. data/lib/r509/io_helpers.rb +7 -7
  117. data/lib/r509/message_digest.rb +5 -6
  118. data/lib/r509/ocsp.rb +11 -13
  119. data/lib/r509/oid_mapper.rb +2 -2
  120. data/lib/r509/private_key.rb +28 -32
  121. data/lib/r509/spki.rb +17 -20
  122. data/lib/r509/subject.rb +26 -27
  123. data/lib/r509/trollop.rb +1 -0
  124. data/lib/r509/validity.rb +30 -21
  125. data/lib/r509/version.rb +4 -2
  126. data/r509.yaml +9 -17
  127. data/spec/asn1_spec.rb +145 -146
  128. data/spec/cert/extensions/authority_info_access_spec.rb +41 -41
  129. data/spec/cert/extensions/authority_key_identifier_spec.rb +29 -23
  130. data/spec/cert/extensions/base_spec.rb +38 -34
  131. data/spec/cert/extensions/basic_constraints_spec.rb +21 -21
  132. data/spec/cert/extensions/certificate_policies_spec.rb +99 -87
  133. data/spec/cert/extensions/crl_distribution_points_spec.rb +24 -25
  134. data/spec/cert/extensions/extended_key_usage_spec.rb +40 -36
  135. data/spec/cert/extensions/inhibit_any_policy_spec.rb +12 -12
  136. data/spec/cert/extensions/key_usage_spec.rb +44 -39
  137. data/spec/cert/extensions/name_constraints_spec.rb +83 -83
  138. data/spec/cert/extensions/ocsp_no_check_spec.rb +10 -10
  139. data/spec/cert/extensions/policy_constraints_spec.rb +19 -19
  140. data/spec/cert/extensions/subject_alternative_name_spec.rb +46 -47
  141. data/spec/cert/extensions/subject_key_identifier_spec.rb +10 -10
  142. data/spec/cert_spec.rb +105 -101
  143. data/spec/certificate_authority/options_builder_spec.rb +90 -90
  144. data/spec/certificate_authority/signer_spec.rb +41 -41
  145. data/spec/config/ca_config_spec.rb +169 -119
  146. data/spec/config/cert_profile_spec.rb +33 -33
  147. data/spec/config/subject_item_policy_spec.rb +22 -22
  148. data/spec/crl/administrator_spec.rb +65 -65
  149. data/spec/crl/reader_writer_spec.rb +20 -19
  150. data/spec/crl/signed_list_spec.rb +26 -26
  151. data/spec/crl/sqlite_reader_writer_spec.rb +42 -0
  152. data/spec/csr_spec.rb +149 -145
  153. data/spec/engine_spec.rb +14 -14
  154. data/spec/fixtures.rb +56 -39
  155. data/spec/fixtures/crl_list.sql +13 -0
  156. data/spec/fixtures/csr1.der +0 -0
  157. data/spec/fixtures/csr1.pem +6 -6
  158. data/spec/message_digest_spec.rb +43 -43
  159. data/spec/ocsp_spec.rb +25 -25
  160. data/spec/oid_mapper_spec.rb +18 -19
  161. data/spec/private_key_spec.rb +79 -81
  162. data/spec/r509_spec.rb +16 -16
  163. data/spec/spec_helper.rb +3 -3
  164. data/spec/spki_spec.rb +94 -94
  165. data/spec/subject_spec.rb +107 -107
  166. data/spec/validity_spec.rb +25 -25
  167. metadata +113 -111
  168. metadata.gz.sig +0 -0
@@ -8,20 +8,20 @@ shared_examples_for "a correct R509 NameConstraints object" do |critical|
8
8
  klass = NameConstraints
9
9
  ef = OpenSSL::X509::ExtensionFactory.new
10
10
  ef.config = OpenSSL::Config.parse(@conf)
11
- openssl_ext = ef.create_extension( extension_name, @extension_value, critical)
12
- @r509_ext = klass.new( openssl_ext )
11
+ openssl_ext = ef.create_extension(extension_name, @extension_value, critical)
12
+ @r509_ext = klass.new(openssl_ext)
13
13
  end
14
14
 
15
15
  it "should have the permitted names" do
16
- @permitted.each_with_index do |name,index|
17
- @r509_ext.permitted.names[index].tag.should == name[:tag]
18
- @r509_ext.permitted.names[index].value.should == name[:value]
16
+ @permitted.each_with_index do |name, index|
17
+ expect(@r509_ext.permitted.names[index].tag).to eq(name[:tag])
18
+ expect(@r509_ext.permitted.names[index].value).to eq(name[:value])
19
19
  end
20
20
  end
21
21
  it "should have the excluded names" do
22
- @excluded.each_with_index do |name,index|
23
- @r509_ext.excluded.names[index].tag.should == name[:tag]
24
- @r509_ext.excluded.names[index].value.should == name[:value]
22
+ @excluded.each_with_index do |name, index|
23
+ expect(@r509_ext.excluded.names[index].tag).to eq(name[:tag])
24
+ expect(@r509_ext.excluded.names[index].value).to eq(name[:value])
25
25
  end
26
26
  end
27
27
  end
@@ -31,24 +31,24 @@ describe R509::Cert::Extensions::NameConstraints do
31
31
 
32
32
  context "validate name constraints"do
33
33
  it "raises an error when not a hash" do
34
- expect { R509::Cert::Extensions::NameConstraints.new( 'a string' ) }.to raise_error(ArgumentError,'name_constraints must be provided as a hash')
34
+ expect { R509::Cert::Extensions::NameConstraints.new('a string') }.to raise_error(ArgumentError, 'name_constraints must be provided as a hash')
35
35
  end
36
36
 
37
37
  it "raises an error when permitted and excluded are empty" do
38
- expect { R509::Cert::Extensions::NameConstraints.new( :permitted => [], :excluded => [] ) }.to raise_error(ArgumentError,'If name_constraints are supplied you must have at least one valid :permitted or :excluded element')
38
+ expect { R509::Cert::Extensions::NameConstraints.new(:permitted => [], :excluded => []) }.to raise_error(ArgumentError, 'If name_constraints are supplied you must have at least one valid :permitted or :excluded element')
39
39
  end
40
40
 
41
41
  it "raises an error when permitted or excluded are not arrays" do
42
- expect { R509::Cert::Extensions::NameConstraints.new( :permitted => 'string', :excluded => 'string' ) }.to raise_error(ArgumentError,'permitted must be an array')
42
+ expect { R509::Cert::Extensions::NameConstraints.new(:permitted => 'string', :excluded => 'string') }.to raise_error(ArgumentError, 'permitted must be an array')
43
43
  end
44
44
 
45
45
  it "raises an error when permitted or excluded elements are not hashes with the required values" do
46
- expect { R509::Cert::Extensions::NameConstraints.new( :permitted => [{"type" => 'DNS'}] ) }.to raise_error(ArgumentError,'Elements within the permitted array must be hashes with both type and value')
47
- expect { R509::Cert::Extensions::NameConstraints.new( :permitted => [{'value' => '127'}] ) }.to raise_error(ArgumentError,'Elements within the permitted array must be hashes with both type and value')
46
+ expect { R509::Cert::Extensions::NameConstraints.new(:permitted => [{ "type" => 'DNS' }]) }.to raise_error(ArgumentError, 'Elements within the permitted array must be hashes with both type and value')
47
+ expect { R509::Cert::Extensions::NameConstraints.new(:permitted => [{ 'value' => '127' }]) }.to raise_error(ArgumentError, 'Elements within the permitted array must be hashes with both type and value')
48
48
  end
49
49
 
50
50
  it "raises an error when an invalid type is specified" do
51
- expect { R509::Cert::Extensions::NameConstraints.new( :permitted => [{:type => 'invalid', :value => '127'}] ) }.to raise_error(ArgumentError,'invalid is not an allowed type. Check R509::ASN1::GeneralName.map_type_to_tag to see a list of types')
51
+ expect { R509::Cert::Extensions::NameConstraints.new(:permitted => [{ :type => 'invalid', :value => '127' }]) }.to raise_error(ArgumentError, 'invalid is not an allowed type. Check R509::ASN1::GeneralName.map_type_to_tag to see a list of types')
52
52
  end
53
53
  end
54
54
 
@@ -56,18 +56,18 @@ describe R509::Cert::Extensions::NameConstraints do
56
56
  context "creation & yaml generation" do
57
57
  context "one permitted" do
58
58
  before :all do
59
- @args = { :permitted => [ { :type => 'DNS', :value => 'domain.com' }], :critical => true }
59
+ @args = { :permitted => [{ :type => 'DNS', :value => 'domain.com' }], :critical => true }
60
60
  @nc = R509::Cert::Extensions::NameConstraints.new(@args)
61
61
  end
62
62
 
63
63
  it "creates extension" do
64
- @nc.permitted.names.size.should == 1
65
- @nc.permitted.names[0].value.should == 'domain.com'
66
- @nc.permitted.names[0].short_type.should == 'DNS'
64
+ expect(@nc.permitted.names.size).to eq(1)
65
+ expect(@nc.permitted.names[0].value).to eq('domain.com')
66
+ expect(@nc.permitted.names[0].short_type).to eq('DNS')
67
67
  end
68
68
 
69
69
  it "builds yaml" do
70
- YAML.load(@nc.to_yaml).should == @args
70
+ expect(YAML.load(@nc.to_yaml)).to eq(@args)
71
71
  end
72
72
  end
73
73
 
@@ -78,41 +78,41 @@ describe R509::Cert::Extensions::NameConstraints do
78
78
  :permitted => [
79
79
  { :type => 'DNS', :value => 'domain.com' },
80
80
  { :type => 'IP', :value => '127.0.0.1/255.255.255.255' },
81
- { :type => 'dirName', :value => {:CN => 'myCN', :O => 'myO', :C => "US" } }
81
+ { :type => 'dirName', :value => { :CN => 'myCN', :O => 'myO', :C => "US" } }
82
82
  ]
83
83
  }
84
84
  @nc = R509::Cert::Extensions::NameConstraints.new(@args)
85
85
  end
86
86
 
87
87
  it "creates extension" do
88
- @nc.permitted.names.size.should == 3
89
- @nc.permitted.names[0].value.should == 'domain.com'
90
- @nc.permitted.names[0].short_type.should == 'DNS'
91
- @nc.permitted.names[1].value.should == '127.0.0.1/255.255.255.255'
92
- @nc.permitted.names[1].short_type.should == 'IP'
93
- @nc.permitted.names[2].value.to_s.should == '/CN=myCN/O=myO/C=US'
94
- @nc.permitted.names[2].short_type.should == 'dirName'
88
+ expect(@nc.permitted.names.size).to eq(3)
89
+ expect(@nc.permitted.names[0].value).to eq('domain.com')
90
+ expect(@nc.permitted.names[0].short_type).to eq('DNS')
91
+ expect(@nc.permitted.names[1].value).to eq('127.0.0.1/255.255.255.255')
92
+ expect(@nc.permitted.names[1].short_type).to eq('IP')
93
+ expect(@nc.permitted.names[2].value.to_s).to eq('/CN=myCN/O=myO/C=US')
94
+ expect(@nc.permitted.names[2].short_type).to eq('dirName')
95
95
  end
96
96
 
97
97
  it "builds yaml" do
98
- YAML.load(@nc.to_yaml).should == @args
98
+ expect(YAML.load(@nc.to_yaml)).to eq(@args)
99
99
  end
100
100
  end
101
101
 
102
102
  context "creates with one excluded" do
103
103
  before :all do
104
- @args = { :excluded => [ { :type => 'DNS', :value => 'domain.com' }], :critical => true }
104
+ @args = { :excluded => [{ :type => 'DNS', :value => 'domain.com' }], :critical => true }
105
105
  @nc = R509::Cert::Extensions::NameConstraints.new(@args)
106
106
  end
107
107
 
108
108
  it "creates extension" do
109
- @nc.excluded.names.size.should == 1
110
- @nc.excluded.names[0].value.should == 'domain.com'
111
- @nc.excluded.names[0].short_type.should == 'DNS'
109
+ expect(@nc.excluded.names.size).to eq(1)
110
+ expect(@nc.excluded.names[0].value).to eq('domain.com')
111
+ expect(@nc.excluded.names[0].short_type).to eq('DNS')
112
112
  end
113
113
 
114
114
  it "builds yaml" do
115
- YAML.load(@nc.to_yaml).should == @args
115
+ expect(YAML.load(@nc.to_yaml)).to eq(@args)
116
116
  end
117
117
  end
118
118
 
@@ -123,24 +123,24 @@ describe R509::Cert::Extensions::NameConstraints do
123
123
  :excluded => [
124
124
  { :type => 'DNS', :value => 'domain.com' },
125
125
  { :type => 'IP', :value => '127.0.0.1/255.255.255.255' },
126
- { :type => 'dirName', :value => {:CN => 'myCN', :O => 'myO', :C => "US" } }
126
+ { :type => 'dirName', :value => { :CN => 'myCN', :O => 'myO', :C => "US" } }
127
127
  ]
128
128
  }
129
129
  @nc = R509::Cert::Extensions::NameConstraints.new(@args)
130
130
  end
131
131
 
132
132
  it "creates extension" do
133
- @nc.excluded.names.size.should == 3
134
- @nc.excluded.names[0].value.should == 'domain.com'
135
- @nc.excluded.names[0].short_type.should == 'DNS'
136
- @nc.excluded.names[1].value.should == '127.0.0.1/255.255.255.255'
137
- @nc.excluded.names[1].short_type.should == 'IP'
138
- @nc.excluded.names[2].value.to_s.should == '/CN=myCN/O=myO/C=US'
139
- @nc.excluded.names[2].short_type.should == 'dirName'
133
+ expect(@nc.excluded.names.size).to eq(3)
134
+ expect(@nc.excluded.names[0].value).to eq('domain.com')
135
+ expect(@nc.excluded.names[0].short_type).to eq('DNS')
136
+ expect(@nc.excluded.names[1].value).to eq('127.0.0.1/255.255.255.255')
137
+ expect(@nc.excluded.names[1].short_type).to eq('IP')
138
+ expect(@nc.excluded.names[2].value.to_s).to eq('/CN=myCN/O=myO/C=US')
139
+ expect(@nc.excluded.names[2].short_type).to eq('dirName')
140
140
  end
141
141
 
142
142
  it "builds yaml" do
143
- YAML.load(@nc.to_yaml).should == @args
143
+ expect(YAML.load(@nc.to_yaml)).to eq(@args)
144
144
  end
145
145
  end
146
146
 
@@ -151,66 +151,66 @@ describe R509::Cert::Extensions::NameConstraints do
151
151
  :excluded => [
152
152
  { :type => 'DNS', :value => 'domain.com' },
153
153
  { :type => 'IP', :value => '127.0.0.1/255.255.255.255' },
154
- { :type => 'dirName', :value => {:CN => 'myCN', :O => 'myO', :C => "US" } }
154
+ { :type => 'dirName', :value => { :CN => 'myCN', :O => 'myO', :C => "US" } }
155
155
  ],
156
156
  :permitted => [
157
157
  { :type => 'DNS', :value => 'domain.com' },
158
158
  { :type => 'IP', :value => '127.0.0.1/255.255.255.255' },
159
- { :type => 'dirName', :value => {:CN => 'myCN', :O => 'myO', :C => "US" } }
159
+ { :type => 'dirName', :value => { :CN => 'myCN', :O => 'myO', :C => "US" } }
160
160
  ]
161
161
  }
162
162
  @nc = R509::Cert::Extensions::NameConstraints.new(@args)
163
163
  end
164
164
 
165
165
  it "creates extension" do
166
- @nc.permitted.names.size.should == 3
167
- @nc.permitted.names[0].value.should == 'domain.com'
168
- @nc.permitted.names[0].short_type.should == 'DNS'
169
- @nc.permitted.names[1].value.should == '127.0.0.1/255.255.255.255'
170
- @nc.permitted.names[1].short_type.should == 'IP'
171
- @nc.permitted.names[2].value.to_s.should == '/CN=myCN/O=myO/C=US'
172
- @nc.permitted.names[2].short_type.should == 'dirName'
173
- @nc.excluded.names.size.should == 3
174
- @nc.excluded.names[0].value.should == 'domain.com'
175
- @nc.excluded.names[0].short_type.should == 'DNS'
176
- @nc.excluded.names[1].value.should == '127.0.0.1/255.255.255.255'
177
- @nc.excluded.names[1].short_type.should == 'IP'
178
- @nc.excluded.names[2].value.to_s.should == '/CN=myCN/O=myO/C=US'
179
- @nc.excluded.names[2].short_type.should == 'dirName'
166
+ expect(@nc.permitted.names.size).to eq(3)
167
+ expect(@nc.permitted.names[0].value).to eq('domain.com')
168
+ expect(@nc.permitted.names[0].short_type).to eq('DNS')
169
+ expect(@nc.permitted.names[1].value).to eq('127.0.0.1/255.255.255.255')
170
+ expect(@nc.permitted.names[1].short_type).to eq('IP')
171
+ expect(@nc.permitted.names[2].value.to_s).to eq('/CN=myCN/O=myO/C=US')
172
+ expect(@nc.permitted.names[2].short_type).to eq('dirName')
173
+ expect(@nc.excluded.names.size).to eq(3)
174
+ expect(@nc.excluded.names[0].value).to eq('domain.com')
175
+ expect(@nc.excluded.names[0].short_type).to eq('DNS')
176
+ expect(@nc.excluded.names[1].value).to eq('127.0.0.1/255.255.255.255')
177
+ expect(@nc.excluded.names[1].short_type).to eq('IP')
178
+ expect(@nc.excluded.names[2].value.to_s).to eq('/CN=myCN/O=myO/C=US')
179
+ expect(@nc.excluded.names[2].short_type).to eq('dirName')
180
180
  end
181
181
 
182
182
  it "builds yaml" do
183
- YAML.load(@nc.to_yaml).should == @args
183
+ expect(YAML.load(@nc.to_yaml)).to eq(@args)
184
184
  end
185
185
  end
186
186
 
187
187
  context "creates with default criticality" do
188
188
  before :all do
189
- @args = { :permitted => [ { :type => 'DNS', :value => 'domain.com' }] }
189
+ @args = { :permitted => [{ :type => 'DNS', :value => 'domain.com' }] }
190
190
  @nc = R509::Cert::Extensions::NameConstraints.new(@args)
191
191
  end
192
192
 
193
193
  it "creates extension" do
194
- @nc.critical?.should == true
194
+ expect(@nc.critical?).to eq(true)
195
195
  end
196
196
 
197
197
  it "builds yaml" do
198
- YAML.load(@nc.to_yaml).should == @args.merge(:critical => true)
198
+ expect(YAML.load(@nc.to_yaml)).to eq(@args.merge(:critical => true))
199
199
  end
200
200
  end
201
201
 
202
202
  context "creates with non-default criticality" do
203
203
  before :all do
204
- @args = { :permitted => [ { :type => 'DNS', :value => 'domain.com' }], :critical => false }
204
+ @args = { :permitted => [{ :type => 'DNS', :value => 'domain.com' }], :critical => false }
205
205
  @nc = R509::Cert::Extensions::NameConstraints.new(@args)
206
206
  end
207
207
 
208
208
  it "creates extension" do
209
- @nc.critical?.should == false
209
+ expect(@nc.critical?).to eq(false)
210
210
  end
211
211
 
212
212
  it "builds yaml" do
213
- YAML.load(@nc.to_yaml).should == @args
213
+ expect(YAML.load(@nc.to_yaml)).to eq(@args)
214
214
  end
215
215
  end
216
216
 
@@ -219,17 +219,17 @@ describe R509::Cert::Extensions::NameConstraints do
219
219
  context "with one permitted name" do
220
220
  before :all do
221
221
  @excluded = []
222
- @permitted = [{:tag => 2, :value => ".whatever.com"}]
222
+ @permitted = [{ :tag => 2, :value => ".whatever.com" }]
223
223
  gns = R509::ASN1::GeneralNames.new
224
224
  @permitted.each do |name|
225
225
  gns.add_item(name)
226
226
  end
227
227
  @conf = []
228
- permitted = gns.names.map { |name|
228
+ permitted = gns.names.map do |name|
229
229
  serialized = name.serialize_name
230
230
  @conf << serialized[:conf]
231
231
  "permitted;" + serialized[:extension_string]
232
- }.join(",")
232
+ end.join(",")
233
233
  @extension_value = permitted
234
234
  @conf = @conf.join("\n")
235
235
  end
@@ -240,17 +240,17 @@ describe R509::Cert::Extensions::NameConstraints do
240
240
  context "with multiple permitted names" do
241
241
  before :all do
242
242
  @excluded = []
243
- @permitted = [{:tag => 2, :value => ".whatever.com"}, {:tag => 1, :value => "user@emaildomain.com" } ]
243
+ @permitted = [{ :tag => 2, :value => ".whatever.com" }, { :tag => 1, :value => "user@emaildomain.com" }]
244
244
  gns = R509::ASN1::GeneralNames.new
245
245
  @permitted.each do |name|
246
246
  gns.add_item(name)
247
247
  end
248
248
  @conf = []
249
- permitted = gns.names.map { |name|
249
+ permitted = gns.names.map do |name|
250
250
  serialized = name.serialize_name
251
251
  @conf << serialized[:conf]
252
252
  "permitted;" + serialized[:extension_string]
253
- }.join(",")
253
+ end.join(",")
254
254
  @extension_value = permitted
255
255
  @conf = @conf.join("\n")
256
256
  end
@@ -261,17 +261,17 @@ describe R509::Cert::Extensions::NameConstraints do
261
261
  context "with one excluded name" do
262
262
  before :all do
263
263
  @permitted = []
264
- @excluded = [{:tag => 7, :value => "127.0.0.1/255.255.255.255"}]
264
+ @excluded = [{ :tag => 7, :value => "127.0.0.1/255.255.255.255" }]
265
265
  egns = R509::ASN1::GeneralNames.new
266
266
  @excluded.each do |name|
267
267
  egns.add_item(name)
268
268
  end
269
269
  @conf = []
270
- excluded = egns.names.map { |name|
270
+ excluded = egns.names.map do |name|
271
271
  serialized = name.serialize_name
272
272
  @conf << serialized[:conf]
273
273
  "excluded;" + serialized[:extension_string]
274
- }.join(",")
274
+ end.join(",")
275
275
  @extension_value = excluded
276
276
  @conf = @conf.join("\n")
277
277
  end
@@ -282,18 +282,18 @@ describe R509::Cert::Extensions::NameConstraints do
282
282
  context "with multiple excluded names" do
283
283
  before :all do
284
284
  @permitted = []
285
- @excluded = [{:tag => 7, :value => "127.0.0.1/255.255.255.255"}, {:tag => 1, :value => "emaildomain.com" } ]
285
+ @excluded = [{ :tag => 7, :value => "127.0.0.1/255.255.255.255" }, { :tag => 1, :value => "emaildomain.com" }]
286
286
  @permitted = []
287
287
  egns = R509::ASN1::GeneralNames.new
288
288
  @excluded.each do |name|
289
289
  egns.add_item(name)
290
290
  end
291
291
  @conf = []
292
- excluded = egns.names.map { |name|
292
+ excluded = egns.names.map do |name|
293
293
  serialized = name.serialize_name
294
294
  @conf << serialized[:conf]
295
295
  "excluded;" + serialized[:extension_string]
296
- }.join(",")
296
+ end.join(",")
297
297
  @extension_value = excluded
298
298
  @conf = @conf.join("\n")
299
299
  end
@@ -303,27 +303,27 @@ describe R509::Cert::Extensions::NameConstraints do
303
303
  end
304
304
  context "with both permitted and excluded names" do
305
305
  before :all do
306
- @excluded = [{:tag => 7, :value => "127.0.0.1/255.255.255.255"}, {:tag => 1, :value => "emaildomain.com" } ]
307
- @permitted = [{:tag => 2, :value => ".whatever.com"}, {:tag => 1, :value => "user@emaildomain.com"} ]
306
+ @excluded = [{ :tag => 7, :value => "127.0.0.1/255.255.255.255" }, { :tag => 1, :value => "emaildomain.com" }]
307
+ @permitted = [{ :tag => 2, :value => ".whatever.com" }, { :tag => 1, :value => "user@emaildomain.com" }]
308
308
  gns = R509::ASN1::GeneralNames.new
309
309
  @permitted.each do |name|
310
310
  gns.add_item(name)
311
311
  end
312
312
  @conf = []
313
- permitted = gns.names.map { |name|
313
+ permitted = gns.names.map do |name|
314
314
  serialized = name.serialize_name
315
315
  @conf << serialized[:conf]
316
316
  "permitted;" + serialized[:extension_string]
317
- }.join(",")
317
+ end.join(",")
318
318
  egns = R509::ASN1::GeneralNames.new
319
319
  @excluded.each do |name|
320
320
  egns.add_item(name)
321
321
  end
322
- excluded = egns.names.map { |name|
322
+ excluded = egns.names.map do |name|
323
323
  serialized = name.serialize_name
324
324
  @conf << serialized[:conf]
325
325
  "excluded;" + serialized[:extension_string]
326
- }.join(",")
326
+ end.join(",")
327
327
  @extension_value = permitted + "," + excluded
328
328
  @conf = @conf.join("\n")
329
329
  end
@@ -7,16 +7,16 @@ shared_examples_for "a correct R509 OCSPNoCheck object" do |critical|
7
7
  extension_name = "noCheck"
8
8
  klass = OCSPNoCheck
9
9
  ef = OpenSSL::X509::ExtensionFactory.new
10
- openssl_ext = ef.create_extension( extension_name, "irrelevant", critical)
11
- @r509_ext = klass.new( openssl_ext )
10
+ openssl_ext = ef.create_extension(extension_name, "irrelevant", critical)
11
+ @r509_ext = klass.new(openssl_ext)
12
12
  end
13
13
 
14
14
  it "has the expected type" do
15
- @r509_ext.oid.should == "noCheck"
15
+ expect(@r509_ext.oid).to eq("noCheck")
16
16
  end
17
17
 
18
18
  it "reports #critical? properly" do
19
- @r509_ext.critical?.should == critical
19
+ expect(@r509_ext.critical?).to eq(critical)
20
20
  end
21
21
  end
22
22
 
@@ -31,11 +31,11 @@ describe R509::Cert::Extensions::OCSPNoCheck do
31
31
  end
32
32
 
33
33
  it "creates extension" do
34
- @no_check.should_not be_nil
34
+ expect(@no_check).not_to be_nil
35
35
  end
36
36
 
37
37
  it "builds yaml" do
38
- YAML.load(@no_check.to_yaml).should == {:critical=>false}
38
+ expect(YAML.load(@no_check.to_yaml)).to eq(:critical => false)
39
39
  end
40
40
  end
41
41
 
@@ -45,11 +45,11 @@ describe R509::Cert::Extensions::OCSPNoCheck do
45
45
  end
46
46
 
47
47
  it "creates extension" do
48
- @no_check.critical?.should be_false
48
+ expect(@no_check.critical?).to be false
49
49
  end
50
50
 
51
51
  it "builds yaml" do
52
- YAML.load(@no_check.to_yaml).should == {:critical => false}
52
+ expect(YAML.load(@no_check.to_yaml)).to eq(:critical => false)
53
53
  end
54
54
  end
55
55
 
@@ -59,11 +59,11 @@ describe R509::Cert::Extensions::OCSPNoCheck do
59
59
  end
60
60
 
61
61
  it "creates extension" do
62
- @no_check.critical?.should be_true
62
+ expect(@no_check.critical?).to be true
63
63
  end
64
64
 
65
65
  it "builds yaml" do
66
- YAML.load(@no_check.to_yaml).should == {:critical => true}
66
+ expect(YAML.load(@no_check.to_yaml)).to eq(:critical => true)
67
67
  end
68
68
  end
69
69
 
@@ -7,15 +7,15 @@ shared_examples_for "a correct R509 PolicyConstraints object" do |critical|
7
7
  extension_name = "policyConstraints"
8
8
  klass = PolicyConstraints
9
9
  ef = OpenSSL::X509::ExtensionFactory.new
10
- openssl_ext = ef.create_extension( extension_name, @extension_value, critical)
11
- @r509_ext = klass.new( openssl_ext )
10
+ openssl_ext = ef.create_extension(extension_name, @extension_value, critical)
11
+ @r509_ext = klass.new(openssl_ext)
12
12
  end
13
13
 
14
14
  it "should have the expected require policy" do
15
- @r509_ext.require_explicit_policy.should == @require_explicit_policy
15
+ expect(@r509_ext.require_explicit_policy).to eq(@require_explicit_policy)
16
16
  end
17
17
  it "should have the expected inhibit mapping" do
18
- @r509_ext.inhibit_policy_mapping.should == @inhibit_policy_mapping
18
+ expect(@r509_ext.inhibit_policy_mapping).to eq(@inhibit_policy_mapping)
19
19
  end
20
20
  end
21
21
 
@@ -24,19 +24,19 @@ describe R509::Cert::Extensions::PolicyConstraints do
24
24
 
25
25
  context "validate policy constraints" do
26
26
  it "raises an error when not a hash" do
27
- expect { R509::Cert::Extensions::PolicyConstraints.new( "string" ) }.to raise_error(ArgumentError,'Policy constraints must be provided as a hash with at least one of the two allowed keys: :inhibit_policy_mapping and :require_explicit_policy')
27
+ expect { R509::Cert::Extensions::PolicyConstraints.new("string") }.to raise_error(ArgumentError, 'Policy constraints must be provided as a hash with at least one of the two allowed keys: :inhibit_policy_mapping and :require_explicit_policy')
28
28
  end
29
29
 
30
30
  it "raises an error when no keys" do
31
- expect { R509::Cert::Extensions::PolicyConstraints.new( {} ) }.to raise_error(ArgumentError,'Policy constraints must have at least one of two keys: :inhibit_policy_mapping and :require_explicit_policy and the value must be non-negative')
31
+ expect { R509::Cert::Extensions::PolicyConstraints.new({}) }.to raise_error(ArgumentError, 'Policy constraints must have at least one of two keys: :inhibit_policy_mapping and :require_explicit_policy and the value must be non-negative')
32
32
  end
33
33
 
34
34
  it "raises an error when inhibit_policy_mapping is not valid" do
35
- expect { R509::Cert::Extensions::PolicyConstraints.new( :inhibit_policy_mapping => -5 ) }.to raise_error(ArgumentError,'inhibit_policy_mapping must be a non-negative integer')
35
+ expect { R509::Cert::Extensions::PolicyConstraints.new(:inhibit_policy_mapping => -5) }.to raise_error(ArgumentError, 'inhibit_policy_mapping must be a non-negative integer')
36
36
  end
37
37
 
38
38
  it "raises an error when require_explicit_policy is not valid" do
39
- expect { R509::Cert::Extensions::PolicyConstraints.new( :require_explicit_policy => -1 ) }.to raise_error(ArgumentError,'require_explicit_policy must be a non-negative integer')
39
+ expect { R509::Cert::Extensions::PolicyConstraints.new(:require_explicit_policy => -1) }.to raise_error(ArgumentError, 'require_explicit_policy must be a non-negative integer')
40
40
  end
41
41
  end
42
42
 
@@ -49,11 +49,11 @@ describe R509::Cert::Extensions::PolicyConstraints do
49
49
  end
50
50
 
51
51
  it "creates extension" do
52
- @pc.require_explicit_policy.should == 1
52
+ expect(@pc.require_explicit_policy).to eq(1)
53
53
  end
54
54
 
55
55
  it "builds yaml" do
56
- YAML.load(@pc.to_yaml).should == @args
56
+ expect(YAML.load(@pc.to_yaml)).to eq(@args)
57
57
  end
58
58
  end
59
59
 
@@ -64,11 +64,11 @@ describe R509::Cert::Extensions::PolicyConstraints do
64
64
  end
65
65
 
66
66
  it "creates extension" do
67
- @pc.inhibit_policy_mapping.should == 1
67
+ expect(@pc.inhibit_policy_mapping).to eq(1)
68
68
  end
69
69
 
70
70
  it "builds yaml" do
71
- YAML.load(@pc.to_yaml).should == @args
71
+ expect(YAML.load(@pc.to_yaml)).to eq(@args)
72
72
  end
73
73
  end
74
74
 
@@ -83,12 +83,12 @@ describe R509::Cert::Extensions::PolicyConstraints do
83
83
  end
84
84
 
85
85
  it "creates extension" do
86
- @pc.inhibit_policy_mapping.should == 1
87
- @pc.require_explicit_policy.should == 3
86
+ expect(@pc.inhibit_policy_mapping).to eq(1)
87
+ expect(@pc.require_explicit_policy).to eq(3)
88
88
  end
89
89
 
90
90
  it "builds yaml" do
91
- YAML.load(@pc.to_yaml).should == @args
91
+ expect(YAML.load(@pc.to_yaml)).to eq(@args)
92
92
  end
93
93
  end
94
94
 
@@ -99,11 +99,11 @@ describe R509::Cert::Extensions::PolicyConstraints do
99
99
  end
100
100
 
101
101
  it "creates extension" do
102
- @pc.critical?.should == true
102
+ expect(@pc.critical?).to eq(true)
103
103
  end
104
104
 
105
105
  it "builds yaml" do
106
- YAML.load(@pc.to_yaml).should == @args.merge(:critical => true)
106
+ expect(YAML.load(@pc.to_yaml)).to eq(@args.merge(:critical => true))
107
107
  end
108
108
  end
109
109
 
@@ -114,11 +114,11 @@ describe R509::Cert::Extensions::PolicyConstraints do
114
114
  end
115
115
 
116
116
  it "creates extension" do
117
- @pc.critical?.should == false
117
+ expect(@pc.critical?).to eq(false)
118
118
  end
119
119
 
120
120
  it "builds yaml" do
121
- YAML.load(@pc.to_yaml).should == @args
121
+ expect(YAML.load(@pc.to_yaml)).to eq(@args)
122
122
  end
123
123
  end
124
124