diff options
Diffstat (limited to 'OpenSSL/Timestamp.html')
-rw-r--r-- | OpenSSL/Timestamp.html | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/OpenSSL/Timestamp.html b/OpenSSL/Timestamp.html index 0d7815f4..7dfb7817 100644 --- a/OpenSSL/Timestamp.html +++ b/OpenSSL/Timestamp.html @@ -88,7 +88,7 @@ <pre class="ruby"><span class="ruby-comment">#Assumes ts.p12 is a PKCS#12-compatible file with a private key</span> <span class="ruby-comment">#and a certificate that has an extended key usage of 'timeStamping'</span> -<span class="ruby-identifier">p12</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">PKCS12</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">'ts.p12'</span>, <span class="ruby-string">'rb'</span>), <span class="ruby-string">'pwd'</span>) +<span class="ruby-identifier">p12</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">PKCS12</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">binread</span>(<span class="ruby-string">'ts.p12'</span>), <span class="ruby-string">'pwd'</span>) <span class="ruby-identifier">md</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Digest</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'SHA1'</span>) <span class="ruby-identifier">hash</span> = <span class="ruby-identifier">md</span>.<span class="ruby-identifier">digest</span>(<span class="ruby-identifier">data</span>) <span class="ruby-comment">#some binary data to be timestamped</span> <span class="ruby-identifier">req</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Timestamp</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span> @@ -105,16 +105,16 @@ <h3 id="module-OpenSSL::Timestamp-label-Verify+a+timestamp+response-3A">Verify a timestamp response:<span><a href="#module-OpenSSL::Timestamp-label-Verify+a+timestamp+response-3A">¶</a> <a href="#top">↑</a></span></h3> <pre>#Assume we have a timestamp token in a file called ts.der -ts = OpenSSL::Timestamp::Response.new(File.open('ts.der', 'rb') +ts = OpenSSL::Timestamp::Response.new(File.binread('ts.der')) #Assume we have the Request for this token in a file called req.der -req = OpenSSL::Timestamp::Request.new(File.open('req.der', 'rb') +req = OpenSSL::Timestamp::Request.new(File.binread('req.der')) # Assume the associated root CA certificate is contained in a # DER-encoded file named root.cer -root = OpenSSL::X509::Certificate.new(File.open('root.cer', 'rb') +root = OpenSSL::X509::Certificate.new(File.binread('root.cer')) # get the necessary intermediate certificates, available in # DER-encoded form in inter1.cer and inter2.cer -inter1 = OpenSSL::X509::Certificate.new(File.open('inter1.cer', 'rb') -inter2 = OpenSSL::X509::Certificate.new(File.open('inter2.cer', 'rb') +inter1 = OpenSSL::X509::Certificate.new(File.binread('inter1.cer')) +inter2 = OpenSSL::X509::Certificate.new(File.binread('inter2.cer')) ts.verify(req, root, inter1, inter2) -> ts or raises an exception if validation fails</pre> </section> |