~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to sample/openssl/smime_read.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'getopts'
 
2
require 'openssl'
 
3
include OpenSSL
 
4
 
 
5
getopts nil, "c:", "k:", "C:"
 
6
 
 
7
cert_file = $OPT_c
 
8
key_file  = $OPT_k
 
9
ca_path   = $OPT_C
 
10
 
 
11
data = $stdin.read
 
12
 
 
13
cert = X509::Certificate.new(File::read(cert_file))
 
14
key = PKey::RSA.new(File::read(key_file))
 
15
p7enc = PKCS7::read_smime(data)
 
16
data = p7enc.decrypt(key, cert)
 
17
 
 
18
store = X509::Store.new
 
19
store.add_path(ca_path)
 
20
p7sig = PKCS7::read_smime(data)
 
21
if p7sig.verify([], store)
 
22
  puts p7sig.data
 
23
end