|
97 | 97 | let(:attestation_certificate_end_time) { Time.now + 60 } |
98 | 98 |
|
99 | 99 | let(:attestation_certificate) do |
100 | | - certificate = OpenSSL::X509::Certificate.new |
101 | | - certificate.version = attestation_certificate_version |
102 | | - certificate.subject = OpenSSL::X509::Name.parse(attestation_certificate_subject) |
103 | | - certificate.issuer = root_certificate.subject |
104 | | - certificate.not_before = attestation_certificate_start_time |
105 | | - certificate.not_after = attestation_certificate_end_time |
106 | | - certificate.public_key = attestation_key |
107 | | - |
108 | 100 | extension_factory = OpenSSL::X509::ExtensionFactory.new |
109 | | - extension_factory.subject_certificate = certificate |
110 | | - extension_factory.issuer_certificate = certificate |
111 | | - |
112 | | - certificate.extensions = [ |
113 | | - extension_factory.create_extension("basicConstraints", attestation_certificate_basic_constraints, true), |
114 | | - ] |
115 | 101 |
|
116 | | - certificate.sign(root_key, "SHA256") |
117 | | - |
118 | | - certificate.to_der |
| 102 | + issue_certificate( |
| 103 | + root_certificate, |
| 104 | + root_key, |
| 105 | + attestation_key, |
| 106 | + version: attestation_certificate_version, |
| 107 | + name: attestation_certificate_subject, |
| 108 | + not_before: attestation_certificate_start_time, |
| 109 | + not_after: attestation_certificate_end_time, |
| 110 | + extensions: [ |
| 111 | + extension_factory.create_extension("basicConstraints", attestation_certificate_basic_constraints, true), |
| 112 | + ] |
| 113 | + ).to_der |
119 | 114 | end |
120 | 115 |
|
121 | 116 | let(:root_key) { create_ec_key } |
122 | 117 | let(:root_certificate_start_time) { Time.now - 1 } |
123 | 118 | let(:root_certificate_end_time) { Time.now + 60 } |
124 | 119 |
|
125 | 120 | let(:root_certificate) do |
126 | | - root_certificate = OpenSSL::X509::Certificate.new |
127 | | - root_certificate.version = attestation_certificate_version |
128 | | - root_certificate.subject = OpenSSL::X509::Name.parse("/DC=org/DC=fake-ca/CN=Fake CA") |
129 | | - root_certificate.issuer = root_certificate.subject |
130 | | - root_certificate.public_key = root_key |
131 | | - root_certificate.not_before = root_certificate_start_time |
132 | | - root_certificate.not_after = root_certificate_end_time |
133 | | - |
134 | | - extension_factory = OpenSSL::X509::ExtensionFactory.new |
135 | | - extension_factory.subject_certificate = root_certificate |
136 | | - extension_factory.issuer_certificate = root_certificate |
137 | | - root_certificate.extensions = [ |
138 | | - extension_factory.create_extension("basicConstraints", "CA:TRUE", true), |
139 | | - extension_factory.create_extension("keyUsage", "keyCertSign,cRLSign", true), |
140 | | - ] |
141 | | - |
142 | | - root_certificate.sign(root_key, "SHA256") |
143 | | - |
144 | | - root_certificate |
| 121 | + create_root_certificate(root_key, not_before: root_certificate_start_time, not_after: root_certificate_end_time) |
145 | 122 | end |
146 | 123 |
|
147 | 124 | let(:statement) do |
|
0 commit comments