r509 0.8.1 → 0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +343 -151
- data/Rakefile +26 -23
- data/bin/r509 +126 -112
- data/bin/r509-parse +24 -24
- data/doc/R509.html +169 -7
- data/doc/R509/ASN1.html +370 -0
- data/doc/R509/ASN1/GeneralName.html +1121 -0
- data/doc/R509/ASN1/GeneralNames.html +843 -0
- data/doc/R509/ASN1/NoticeReference.html +392 -0
- data/doc/R509/ASN1/PolicyInformation.html +387 -0
- data/doc/R509/ASN1/PolicyQualifiers.html +455 -0
- data/doc/R509/ASN1/UserNotice.html +386 -0
- data/doc/R509/{Crl.html → CRL.html} +7 -7
- data/doc/R509/CRL/Administrator.html +1559 -0
- data/doc/R509/{Crl/Parser.html → CRL/SignedList.html} +501 -210
- data/doc/R509/{Csr.html → CSR.html} +444 -314
- data/doc/R509/Cert.html +866 -617
- data/doc/R509/Cert/Extensions.html +52 -41
- data/doc/R509/Cert/Extensions/AuthorityInfoAccess.html +70 -35
- data/doc/R509/Cert/Extensions/AuthorityKeyIdentifier.html +387 -4
- data/doc/R509/Cert/Extensions/BasicConstraints.html +61 -25
- data/doc/R509/Cert/Extensions/CRLDistributionPoints.html +354 -0
- data/doc/R509/Cert/Extensions/CertificatePolicies.html +340 -0
- data/doc/R509/Cert/Extensions/ExtendedKeyUsage.html +440 -49
- data/doc/R509/Cert/Extensions/{CrlDistributionPoints.html → InhibitAnyPolicy.html} +52 -35
- data/doc/R509/Cert/Extensions/KeyUsage.html +247 -121
- data/doc/R509/Cert/Extensions/NameConstraints.html +445 -0
- data/doc/R509/Cert/Extensions/OCSPNoCheck.html +239 -0
- data/doc/R509/Cert/Extensions/PolicyConstraints.html +424 -0
- data/doc/R509/Cert/Extensions/SubjectAlternativeName.html +437 -62
- data/doc/R509/Cert/Extensions/SubjectKeyIdentifier.html +52 -10
- data/doc/R509/CertificateAuthority.html +4 -4
- data/doc/R509/CertificateAuthority/Signer.html +154 -187
- data/doc/R509/Config.html +6 -6
- data/doc/R509/Config/{CaConfig.html → CAConfig.html} +451 -348
- data/doc/R509/Config/{CaConfigPool.html → CAConfigPool.html} +47 -47
- data/doc/R509/Config/CAProfile.html +1015 -0
- data/doc/R509/Config/SubjectItemPolicy.html +86 -86
- data/doc/R509/IOHelpers.html +22 -22
- data/doc/R509/MessageDigest.html +14 -14
- data/doc/R509/NameSanitizer.html +53 -53
- data/doc/R509/{Ocsp.html → OCSP.html} +9 -9
- data/doc/R509/{Ocsp → OCSP}/Request.html +7 -7
- data/doc/R509/{Ocsp → OCSP}/Request/Nonce.html +56 -11
- data/doc/R509/{Ocsp → OCSP}/Response.html +44 -44
- data/doc/R509/{OidMapper.html → OIDMapper.html} +23 -39
- data/doc/R509/PrivateKey.html +415 -168
- data/doc/R509/R509Error.html +3 -3
- data/doc/R509/{Spki.html → SPKI.html} +354 -192
- data/doc/R509/Subject.html +224 -113
- data/doc/R509/Validity.html +27 -5
- data/doc/R509/Validity/Checker.html +13 -13
- data/doc/R509/Validity/DefaultChecker.html +13 -13
- data/doc/R509/Validity/DefaultWriter.html +14 -14
- data/doc/R509/Validity/Status.html +39 -39
- data/doc/R509/Validity/Writer.html +18 -18
- data/doc/_index.html +138 -35
- data/doc/class_list.html +1 -1
- data/doc/css/style.css +10 -0
- data/doc/file.README.html +368 -171
- data/doc/file.r509.html +92 -69
- data/doc/frames.html +1 -1
- data/doc/index.html +368 -171
- data/doc/method_list.html +910 -390
- data/doc/top-level-namespace.html +3 -3
- data/lib/r509.rb +32 -16
- data/lib/r509/asn1.rb +375 -0
- data/lib/r509/cert.rb +381 -364
- data/lib/r509/cert/extensions.rb +443 -76
- data/lib/r509/certificate_authority.rb +407 -0
- data/lib/r509/config.rb +547 -351
- data/lib/r509/crl.rb +336 -366
- data/lib/r509/csr.rb +278 -289
- data/lib/r509/ec-hack.rb +37 -0
- data/lib/r509/exceptions.rb +3 -3
- data/lib/r509/io_helpers.rb +44 -44
- data/lib/r509/message_digest.rb +53 -0
- data/lib/r509/ocsp.rb +80 -70
- data/lib/r509/oid_mapper.rb +32 -0
- data/lib/r509/private_key.rb +228 -0
- data/lib/r509/spki.rb +145 -93
- data/lib/r509/subject.rb +203 -110
- data/lib/r509/validity.rb +70 -68
- data/lib/r509/version.rb +2 -2
- data/r509.yaml +92 -69
- data/spec/asn1_spec.rb +402 -0
- data/spec/cert/extensions_spec.rb +957 -494
- data/spec/cert_spec.rb +382 -307
- data/spec/certificate_authority_spec.rb +668 -250
- data/spec/config_spec.rb +515 -302
- data/spec/crl_spec.rb +197 -198
- data/spec/csr_spec.rb +334 -289
- data/spec/fixtures.rb +247 -171
- data/spec/fixtures/cert1.der +0 -0
- data/spec/fixtures/cert1.pem +0 -0
- data/spec/fixtures/cert1_public_key_modulus.txt +0 -0
- data/spec/fixtures/cert3.p12 +0 -0
- data/spec/fixtures/cert3.pem +0 -0
- data/spec/fixtures/cert3_key.pem +0 -0
- data/spec/fixtures/cert3_key_des3.pem +0 -0
- data/spec/fixtures/cert4.pem +0 -0
- data/spec/fixtures/cert5.pem +0 -0
- data/spec/fixtures/cert6.pem +0 -0
- data/spec/fixtures/cert_expired.pem +0 -0
- data/spec/fixtures/cert_inhibit.pem +24 -0
- data/spec/fixtures/cert_name_constraints.pem +29 -0
- data/spec/fixtures/cert_not_yet_valid.pem +0 -0
- data/spec/fixtures/cert_ocsp_no_check.pem +18 -0
- data/spec/fixtures/cert_policy_constraints.pem +31 -0
- data/spec/fixtures/cert_san.pem +0 -0
- data/spec/fixtures/cert_san2.pem +0 -0
- data/spec/fixtures/cert_unknown_extension.pem +28 -0
- data/spec/fixtures/config_pool_test_minimal.yaml +11 -11
- data/spec/fixtures/config_test.yaml +54 -36
- data/spec/fixtures/config_test_dsa.yaml +35 -0
- data/spec/fixtures/config_test_ec.yaml +35 -0
- data/spec/fixtures/config_test_engine_key.yaml +5 -5
- data/spec/fixtures/config_test_engine_no_key_name.yaml +4 -4
- data/spec/fixtures/config_test_minimal.yaml +4 -4
- data/spec/fixtures/config_test_password.yaml +5 -5
- data/spec/fixtures/config_test_various.yaml +111 -74
- data/spec/fixtures/crl_list_file.txt +0 -0
- data/spec/fixtures/crl_with_reason.pem +0 -0
- data/spec/fixtures/csr1.der +0 -0
- data/spec/fixtures/csr1.pem +0 -0
- data/spec/fixtures/csr1_key.der +0 -0
- data/spec/fixtures/csr1_key.pem +0 -0
- data/spec/fixtures/csr1_key_encrypted_des3.pem +0 -0
- data/spec/fixtures/csr1_newlines.pem +0 -0
- data/spec/fixtures/csr1_no_begin_end.pem +0 -0
- data/spec/fixtures/csr1_public_key_modulus.txt +0 -0
- data/spec/fixtures/csr2.pem +0 -0
- data/spec/fixtures/csr2_key.pem +0 -0
- data/spec/fixtures/csr3.pem +0 -0
- data/spec/fixtures/csr4.pem +0 -0
- data/spec/fixtures/csr_dsa.pem +0 -0
- data/spec/fixtures/csr_invalid_signature.pem +0 -0
- data/spec/fixtures/dsa_key.pem +0 -0
- data/spec/fixtures/dsa_root.cer +28 -0
- data/spec/fixtures/dsa_root.key +20 -0
- data/spec/fixtures/ec_csr2.der +0 -0
- data/spec/fixtures/ec_csr2.pem +8 -0
- data/spec/fixtures/ec_key1.der +0 -0
- data/spec/fixtures/ec_key1.pem +6 -0
- data/spec/fixtures/ec_key1_encrypted.pem +9 -0
- data/spec/fixtures/ec_key2.pem +6 -0
- data/spec/fixtures/hmacsha1.sig +1 -0
- data/spec/fixtures/hmacsha512.sig +1 -0
- data/spec/fixtures/key4.pem +0 -0
- data/spec/fixtures/key4_encrypted_des3.pem +0 -0
- data/spec/fixtures/missing_key_identifier_ca.cer +0 -0
- data/spec/fixtures/missing_key_identifier_ca.key +0 -0
- data/spec/fixtures/ocsptest.r509.local.pem +0 -0
- data/spec/fixtures/ocsptest.r509.local_ocsp_request.der +0 -0
- data/spec/fixtures/ocsptest2.r509.local.pem +0 -0
- data/spec/fixtures/second_ca.cer +0 -0
- data/spec/fixtures/second_ca.key +0 -0
- data/spec/fixtures/spkac.der +0 -0
- data/spec/fixtures/spkac.txt +0 -0
- data/spec/fixtures/spkac_dsa.txt +1 -1
- data/spec/fixtures/spkac_dsa_no_verify.txt +1 -0
- data/spec/fixtures/spkac_ec.txt +1 -0
- data/spec/fixtures/spkac_rsa_newlines.txt +13 -0
- data/spec/fixtures/stca.pem +0 -0
- data/spec/fixtures/stca_ocsp_request.der +0 -0
- data/spec/fixtures/stca_ocsp_response.der +0 -0
- data/spec/fixtures/test1.csr +0 -0
- data/spec/fixtures/test_ca.cer +0 -0
- data/spec/fixtures/test_ca.key +0 -0
- data/spec/fixtures/test_ca.p12 +0 -0
- data/spec/fixtures/test_ca_des3.key +0 -0
- data/spec/fixtures/test_ca_ec.cer +14 -0
- data/spec/fixtures/test_ca_ec.key +6 -0
- data/spec/fixtures/test_ca_ec_ee.cer +22 -0
- data/spec/fixtures/test_ca_ec_ee.key +6 -0
- data/spec/fixtures/test_ca_ocsp.cer +0 -0
- data/spec/fixtures/test_ca_ocsp.key +0 -0
- data/spec/fixtures/test_ca_ocsp.p12 +0 -0
- data/spec/fixtures/test_ca_ocsp_chain.txt +0 -0
- data/spec/fixtures/test_ca_ocsp_response.der +0 -0
- data/spec/fixtures/test_ca_subroot.cer +0 -0
- data/spec/fixtures/test_ca_subroot.key +0 -0
- data/spec/fixtures/test_ca_subroot_ocsp.cer +0 -0
- data/spec/fixtures/test_ca_subroot_ocsp.key +0 -0
- data/spec/fixtures/test_ca_subroot_ocsp_response.der +0 -0
- data/spec/fixtures/unknown_oid.csr +0 -0
- data/spec/message_digest_spec.rb +104 -84
- data/spec/ocsp_spec.rb +105 -105
- data/spec/oid_mapper_spec.rb +21 -21
- data/spec/private_key_spec.rb +275 -0
- data/spec/r509_spec.rb +35 -0
- data/spec/spec_helper.rb +15 -6
- data/spec/spki_spec.rb +221 -142
- data/spec/subject_spec.rb +232 -164
- data/spec/validity_spec.rb +91 -91
- metadata +79 -25
- data/doc/R509/Config/CaProfile.html +0 -651
- data/doc/R509/Crl/Administrator.html +0 -2073
- data/lib/r509/certificateauthority.rb +0 -290
- data/lib/r509/messagedigest.rb +0 -49
- data/lib/r509/oidmapper.rb +0 -32
- data/lib/r509/privatekey.rb +0 -185
- data/spec/privatekey_spec.rb +0 -198
data/Rakefile
CHANGED
@@ -5,34 +5,37 @@ require "#{File.dirname(__FILE__)}/lib/r509/version"
|
|
5
5
|
task :default => :spec
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
desc 'Run all rspec tests with rcov (1.8 only)'
|
9
|
-
RSpec::Core::RakeTask.new(:rcov) do |t|
|
10
|
-
t.rcov_opts = %q[--exclude "spec,gems"]
|
11
|
-
t.rcov = true
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
8
|
namespace :gem do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
9
|
+
desc 'Build the gem'
|
10
|
+
task :build do
|
11
|
+
puts `yard`
|
12
|
+
puts `gem build r509.gemspec`
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Install gem'
|
16
|
+
task :install do
|
17
|
+
puts `gem install r509-#{R509::VERSION}.gem`
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Uninstall gem'
|
21
|
+
task :uninstall do
|
22
|
+
puts `gem uninstall r509`
|
23
|
+
end
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
desc "Open an irb session with the lib dir included"
|
27
|
+
task :irb do
|
28
|
+
$:.unshift File.expand_path("../../lib", __FILE__)
|
29
|
+
$:.unshift File.expand_path("../", __FILE__)
|
30
|
+
require 'r509'
|
31
|
+
require 'irb'
|
32
|
+
ARGV.clear
|
33
|
+
IRB.start
|
31
34
|
end
|
32
35
|
|
33
36
|
|
34
37
|
desc 'Build yard documentation'
|
35
38
|
task :yard do
|
36
|
-
|
37
|
-
|
39
|
+
puts `yard`
|
40
|
+
`open doc/index.html`
|
38
41
|
end
|
data/bin/r509
CHANGED
@@ -1,143 +1,157 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
3
|
require 'r509'
|
4
|
-
require 'r509/version'
|
5
|
-
require 'openssl'
|
6
4
|
require 'trollop'
|
7
5
|
|
8
6
|
opts = Trollop::options do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
opt :interactive, "Interactive CSR/self-signed certificate generation. Overrides all flags other than keyout and out."
|
8
|
+
opt :subject, "X509 subject / delimited. Example: /CN=test.com/O=Org/C=US/ST=Illinois/L=Chicago", :type => :string
|
9
|
+
opt :message_digest, "Message digest to use. sha1, sha224, sha256, sha384, sha512, md5", :type => :string, :default => 'sha1'
|
10
|
+
opt :duration, "Self-sign the certificate with the duration (in days) specified.", :type => :integer
|
11
|
+
opt :bits, "Bit length of generated key. Ignored for EC.", :type => :integer, :default => 2048
|
12
|
+
opt :curve_name, "Name of elliptic curve to use. Only used for EC.", :type => :string, :default => 'secp384r1'
|
13
|
+
opt :keyout, "File name to save generated key.", :type => :string
|
14
|
+
opt :out, "File name to save generated CSR or self-signed certificate", :type => :string
|
15
|
+
opt :type, "Type of key to generate. RSA/DSA/EC", :type => :string, :default => "RSA"
|
16
|
+
version "r509 #{R509::VERSION}"
|
17
17
|
end
|
18
18
|
|
19
19
|
if opts[:interactive] == true or opts[:subject].nil? then
|
20
|
+
if opts[:type].upcase == "RSA" or opts[:type].upcase == "DSA"
|
20
21
|
print "CSR Bit Strength (2048):"
|
21
22
|
bit_strength = gets.chomp
|
22
23
|
bit_strength = (bit_strength.to_i > 0)? bit_strength.to_i : 2048
|
24
|
+
elsif opts[:type].upcase == "EC"
|
25
|
+
print "Curve Name (secp384r1):"
|
26
|
+
curve_name = gets.chomp
|
27
|
+
curve_name = (not curve_name.empty?)? curve_name : 'secp384r1'
|
28
|
+
else
|
29
|
+
puts "Invalid key type specified. RSA/DSA/EC"
|
30
|
+
exit
|
31
|
+
end
|
23
32
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
print "Message Digest (sha1):"
|
34
|
+
md = gets.chomp
|
35
|
+
opts[:message_digest] = case md
|
36
|
+
when 'sha1' then 'sha1'
|
37
|
+
when 'sha224' then 'sha224'
|
38
|
+
when 'sha256' then 'sha256'
|
39
|
+
when 'sha384' then 'sha384'
|
40
|
+
when 'sha512' then 'sha512'
|
41
|
+
when 'md5' then 'md5'
|
42
|
+
else 'sha1'
|
43
|
+
end
|
33
44
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
45
|
+
subject = []
|
46
|
+
print "C (US): "
|
47
|
+
c = gets.chomp
|
48
|
+
c = c.empty? ? 'US':c;
|
49
|
+
subject.push ['C',c]
|
39
50
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
51
|
+
print "ST (Illinois): "
|
52
|
+
st = gets.chomp
|
53
|
+
st = st.empty? ? 'Illinois':st;
|
54
|
+
subject.push ['ST',st]
|
44
55
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
56
|
+
print "L (Chicago): "
|
57
|
+
l = gets.chomp
|
58
|
+
l = l.empty? ? 'Chicago':l;
|
59
|
+
subject.push ['L',l]
|
49
60
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
61
|
+
print "O (r509 LLC): "
|
62
|
+
o = gets.chomp
|
63
|
+
o = o.empty? ? 'r509 LLC':o;
|
64
|
+
subject.push ['O',o]
|
54
65
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
66
|
+
print "OU (null by default): "
|
67
|
+
ou = gets.chomp
|
68
|
+
if(!ou.empty?) then
|
69
|
+
subject.push ['OU',ou]
|
70
|
+
end
|
60
71
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
+
print "CN: "
|
73
|
+
subject.push ['CN',gets.chomp]
|
74
|
+
print "SAN Domains (comma separated):"
|
75
|
+
san_domains = []
|
76
|
+
san_domains = gets.chomp.split(',').collect { |domain| domain.strip }
|
77
|
+
csr = R509::CSR.new(
|
78
|
+
:subject => subject,
|
79
|
+
:bit_strength => bit_strength,
|
80
|
+
:type => opts[:type].downcase.to_sym,
|
81
|
+
:curve_name => curve_name,
|
82
|
+
:san_names => san_domains,
|
83
|
+
:message_digest => opts[:message_digest]
|
84
|
+
)
|
72
85
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
86
|
+
selfsign = 0
|
87
|
+
print "Self-signed cert duration in days (null disables self-sign):"
|
88
|
+
selfsign_input = gets.chomp
|
89
|
+
if selfsign_input.to_i > 0
|
90
|
+
selfsign = selfsign_input.to_i
|
91
|
+
end
|
79
92
|
elsif not opts[:subject].nil?
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
93
|
+
subject = OpenSSL::X509::Name.new
|
94
|
+
opts[:subject].chomp.split('/').each { |item|
|
95
|
+
if item != '' then
|
96
|
+
value = item.split('=')
|
97
|
+
subject.add_entry(value[0],value[1])
|
98
|
+
end
|
99
|
+
}
|
100
|
+
csr = R509::CSR.new(
|
101
|
+
:subject => subject,
|
102
|
+
:bit_strength => opts[:bits],
|
103
|
+
:type => opts[:type].downcase.to_sym,
|
104
|
+
:curve_name => opts[:curve_name],
|
105
|
+
:message_digest => opts[:message_digest]
|
106
|
+
)
|
107
|
+
selfsign = opts[:duration] || 0
|
94
108
|
end
|
95
109
|
|
96
110
|
if selfsign > 0
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
111
|
+
ca = R509::CertificateAuthority::Signer.new
|
112
|
+
cert = ca.selfsign(
|
113
|
+
:csr => csr,
|
114
|
+
:not_after => Time.now.to_i+86400*selfsign,
|
115
|
+
:message_digest => opts[:message_digest]
|
116
|
+
)
|
117
|
+
if opts[:keyout].nil?
|
118
|
+
puts csr.key.to_pem
|
119
|
+
else
|
120
|
+
File.open(opts[:keyout], 'w') {|f| f.write(csr.key.to_pem) }
|
121
|
+
end
|
122
|
+
if opts[:out].nil?
|
123
|
+
puts cert.to_pem
|
124
|
+
else
|
125
|
+
File.open(opts[:out], 'w') {|f| f.write(cert.to_pem) }
|
126
|
+
end
|
113
127
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
128
|
+
puts cert.subject
|
129
|
+
if not cert.san.nil?
|
130
|
+
puts "SAN(s): "+cert.san.names.map { |n| n.value }.join(", ")
|
131
|
+
end
|
118
132
|
else
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
133
|
+
if opts[:keyout].nil?
|
134
|
+
puts csr.key.to_pem
|
135
|
+
else
|
136
|
+
File.open(opts[:keyout], 'w') {|f| f.write(csr.key.to_pem) }
|
137
|
+
end
|
124
138
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
139
|
+
if opts[:out].nil?
|
140
|
+
puts csr.to_pem
|
141
|
+
else
|
142
|
+
File.open(opts[:out], 'w') {|f| f.write(csr.to_pem) }
|
143
|
+
end
|
130
144
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
145
|
+
puts csr.subject
|
146
|
+
if not csr.san.nil?
|
147
|
+
puts "SAN(s): "+csr.san.names.map{|n| n.value}.join(", ")
|
148
|
+
end
|
135
149
|
end
|
136
150
|
|
137
151
|
if RUBY_PLATFORM.match('darwin') != nil then
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
152
|
+
if selfsign > 0
|
153
|
+
IO.popen('pbcopy','w').puts cert
|
154
|
+
else
|
155
|
+
IO.popen('pbcopy','w').puts csr
|
156
|
+
end
|
143
157
|
end
|
data/bin/r509-parse
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
3
|
require 'r509'
|
4
|
-
require 'r509/version'
|
5
|
-
require 'openssl'
|
6
4
|
|
7
5
|
if ARGV[0].nil? then
|
8
|
-
|
9
|
-
|
6
|
+
puts "CSR and certificate parsing using r509 v#{R509::VERSION}."
|
7
|
+
puts "Usage: r509-parse <cert or csr>"
|
10
8
|
else
|
9
|
+
begin
|
10
|
+
csr = R509::CSR.load_from_file ARGV[0]
|
11
|
+
rescue
|
12
|
+
end
|
13
|
+
if not csr.nil?
|
14
|
+
puts "Subject: #{csr.subject}"
|
15
|
+
puts "Algorithm: #{csr.signature_algorithm}"
|
16
|
+
puts "SAN Names: #{csr.san.names.map { |n| n.value }.join(" , ")}"
|
17
|
+
else
|
11
18
|
begin
|
12
|
-
|
19
|
+
cert = R509::Cert.load_from_file ARGV[0]
|
13
20
|
rescue
|
14
21
|
end
|
15
|
-
if not
|
16
|
-
|
17
|
-
|
22
|
+
if not cert.nil?
|
23
|
+
puts "Subject: #{cert.subject}"
|
24
|
+
puts "Issuer: #{cert.issuer}"
|
25
|
+
puts "Algorithm: #{cert.signature_algorithm}"
|
26
|
+
puts "SAN Names: #{cert.san.names.map { |n| n.value }.join(" , ")}"
|
27
|
+
puts "Not Before: #{cert.not_before}"
|
28
|
+
puts "Not After: #{cert.not_after}"
|
29
|
+
puts "Serial (Hex): #{cert.hexserial}"
|
30
|
+
puts "Serial (Decimal): #{cert.serial}"
|
18
31
|
else
|
19
|
-
|
20
|
-
cert = R509::Cert.load_from_file ARGV[0]
|
21
|
-
rescue
|
22
|
-
end
|
23
|
-
if not cert.nil?
|
24
|
-
puts "Subject: #{cert.subject}"
|
25
|
-
puts "Issuer: #{cert.issuer}"
|
26
|
-
puts "SAN Names: #{cert.san_names.join(" , ")}"
|
27
|
-
puts "Not Before: #{cert.not_before}"
|
28
|
-
puts "Not After: #{cert.not_after}"
|
29
|
-
puts "Serial (Hex): #{cert.serial.to_s(16).upcase}"
|
30
|
-
puts "Serial (Decimal): #{cert.serial}"
|
31
|
-
else
|
32
|
-
puts "Failed to parse CSR or certificate"
|
33
|
-
end
|
32
|
+
puts "Failed to parse CSR or certificate"
|
34
33
|
end
|
34
|
+
end
|
35
35
|
end
|
data/doc/R509.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: R509
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.
|
9
|
+
— Documentation by YARD 0.8.5
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
<dt class="r1 last">Defined in:</dt>
|
82
82
|
<dd class="r1 last">lib/r509.rb<span class="defines">,<br />
|
83
|
-
lib/r509/csr.rb,<br /> lib/r509/crl.rb,<br /> lib/r509/
|
83
|
+
lib/r509/csr.rb,<br /> lib/r509/crl.rb,<br /> lib/r509/cert.rb,<br /> lib/r509/spki.rb,<br /> lib/r509/asn1.rb,<br /> lib/r509/config.rb,<br /> lib/r509/subject.rb,<br /> lib/r509/version.rb,<br /> lib/r509/oid_mapper.rb,<br /> lib/r509/exceptions.rb,<br /> lib/r509/io_helpers.rb,<br /> lib/r509/private_key.rb,<br /> lib/r509/message_digest.rb,<br /> lib/r509/cert/extensions.rb</span>
|
84
84
|
</dd>
|
85
85
|
|
86
86
|
</dl>
|
@@ -102,11 +102,11 @@ support.</p>
|
|
102
102
|
<p class="children">
|
103
103
|
|
104
104
|
|
105
|
-
<strong class="modules">Modules:</strong> <span class='object_link'><a href="R509/CertificateAuthority.html" title="R509::CertificateAuthority (module)">CertificateAuthority</a></span>, <span class='object_link'><a href="R509/Config.html" title="R509::Config (module)">Config</a></span>, <span class='object_link'><a href="R509/
|
105
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="R509/ASN1.html" title="R509::ASN1 (module)">ASN1</a></span>, <span class='object_link'><a href="R509/CRL.html" title="R509::CRL (module)">CRL</a></span>, <span class='object_link'><a href="R509/CertificateAuthority.html" title="R509::CertificateAuthority (module)">CertificateAuthority</a></span>, <span class='object_link'><a href="R509/Config.html" title="R509::Config (module)">Config</a></span>, <span class='object_link'><a href="R509/IOHelpers.html" title="R509::IOHelpers (module)">IOHelpers</a></span>, <span class='object_link'><a href="R509/OCSP.html" title="R509::OCSP (module)">OCSP</a></span>, <span class='object_link'><a href="R509/OIDMapper.html" title="R509::OIDMapper (module)">OIDMapper</a></span>, <span class='object_link'><a href="R509/Validity.html" title="R509::Validity (module)">Validity</a></span>
|
106
106
|
|
107
107
|
|
108
108
|
|
109
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="R509/
|
109
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="R509/CSR.html" title="R509::CSR (class)">CSR</a></span>, <span class='object_link'><a href="R509/Cert.html" title="R509::Cert (class)">Cert</a></span>, <span class='object_link'><a href="R509/MessageDigest.html" title="R509::MessageDigest (class)">MessageDigest</a></span>, <span class='object_link'><a href="R509/NameSanitizer.html" title="R509::NameSanitizer (class)">NameSanitizer</a></span>, <span class='object_link'><a href="R509/PrivateKey.html" title="R509::PrivateKey (class)">PrivateKey</a></span>, <span class='object_link'><a href="R509/R509Error.html" title="R509::R509Error (class)">R509Error</a></span>, <span class='object_link'><a href="R509/SPKI.html" title="R509::SPKI (class)">SPKI</a></span>, <span class='object_link'><a href="R509/Subject.html" title="R509::Subject (class)">Subject</a></span>
|
110
110
|
|
111
111
|
|
112
112
|
</p>
|
@@ -129,7 +129,7 @@ support.</p>
|
|
129
129
|
|
130
130
|
</div>
|
131
131
|
</dt>
|
132
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.
|
132
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.9</span><span class='tstring_end'>"</span></span></pre></dd>
|
133
133
|
|
134
134
|
</dl>
|
135
135
|
|
@@ -140,14 +140,176 @@ support.</p>
|
|
140
140
|
|
141
141
|
|
142
142
|
|
143
|
+
|
144
|
+
<h2>
|
145
|
+
Class Method Summary
|
146
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
147
|
+
</h2>
|
148
|
+
|
149
|
+
<ul class="summary">
|
150
|
+
|
151
|
+
<li class="public ">
|
152
|
+
<span class="summary_signature">
|
153
|
+
|
154
|
+
<a href="#ec_supported%3F-class_method" title="ec_supported? (class method)">+ (Boolean) <strong>ec_supported?</strong> </a>
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
</span>
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
169
|
+
|
170
|
+
</li>
|
171
|
+
|
172
|
+
|
173
|
+
<li class="public ">
|
174
|
+
<span class="summary_signature">
|
175
|
+
|
176
|
+
<a href="#print_debug-class_method" title="print_debug (class method)">+ (Object) <strong>print_debug</strong> </a>
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
</span>
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
<span class="summary_desc"><div class='inline'>
|
191
|
+
<p>print version information to console.</p>
|
192
|
+
</div></span>
|
193
|
+
|
194
|
+
</li>
|
195
|
+
|
196
|
+
|
197
|
+
</ul>
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
<div id="class_method_details" class="method_details_list">
|
203
|
+
<h2>Class Method Details</h2>
|
204
|
+
|
205
|
+
|
206
|
+
<div class="method_details first">
|
207
|
+
<h3 class="signature first" id="ec_supported?-class_method">
|
208
|
+
|
209
|
+
+ (<tt>Boolean</tt>) <strong>ec_supported?</strong>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
</h3><div class="docstring">
|
216
|
+
<div class="discussion">
|
217
|
+
|
218
|
+
|
219
|
+
</div>
|
220
|
+
</div>
|
221
|
+
<div class="tags">
|
222
|
+
|
223
|
+
<p class="tag_title">Returns:</p>
|
224
|
+
<ul class="return">
|
225
|
+
|
226
|
+
<li>
|
227
|
+
|
228
|
+
|
229
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
</li>
|
234
|
+
|
235
|
+
</ul>
|
236
|
+
|
237
|
+
</div><table class="source_code">
|
238
|
+
<tr>
|
239
|
+
<td>
|
240
|
+
<pre class="lines">
|
241
|
+
|
242
|
+
|
243
|
+
27
|
244
|
+
28
|
245
|
+
29</pre>
|
246
|
+
</td>
|
247
|
+
<td>
|
248
|
+
<pre class="code"><span class="info file"># File 'lib/r509.rb', line 27</span>
|
249
|
+
|
250
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ec_supported?'>ec_supported?</span>
|
251
|
+
<span class='lparen'>(</span><span class='kw'>not</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>PKey</span><span class='op'>::</span><span class='const'>EC</span><span class='op'>::</span><span class='const'>UNSUPPORTED</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
252
|
+
<span class='kw'>end</span></pre>
|
253
|
+
</td>
|
254
|
+
</tr>
|
255
|
+
</table>
|
256
|
+
</div>
|
257
|
+
|
258
|
+
<div class="method_details ">
|
259
|
+
<h3 class="signature " id="print_debug-class_method">
|
260
|
+
|
261
|
+
+ (<tt>Object</tt>) <strong>print_debug</strong>
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
</h3><div class="docstring">
|
268
|
+
<div class="discussion">
|
269
|
+
|
270
|
+
<p>print version information to console</p>
|
271
|
+
|
272
|
+
|
273
|
+
</div>
|
274
|
+
</div>
|
275
|
+
<div class="tags">
|
276
|
+
|
143
277
|
|
278
|
+
</div><table class="source_code">
|
279
|
+
<tr>
|
280
|
+
<td>
|
281
|
+
<pre class="lines">
|
282
|
+
|
283
|
+
|
284
|
+
20
|
285
|
+
21
|
286
|
+
22
|
287
|
+
23
|
288
|
+
24
|
289
|
+
25</pre>
|
290
|
+
</td>
|
291
|
+
<td>
|
292
|
+
<pre class="code"><span class="info file"># File 'lib/r509.rb', line 20</span>
|
293
|
+
|
294
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_print_debug'>print_debug</span>
|
295
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>r509 v</span><span class='embexpr_beg'>#{</span><span class='const'>R509</span><span class='op'>::</span><span class='const'>VERSION</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
296
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>OPENSSL_VERSION</span>
|
297
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Ruby </span><span class='embexpr_beg'>#{</span><span class='const'>RUBY_VERSION</span><span class='rbrace'>}</span><span class='tstring_content'>-p</span><span class='embexpr_beg'>#{</span><span class='const'>RUBY_PATCHLEVEL</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
298
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Elliptic curve support: </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ec_supported?'>ec_supported?</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
299
|
+
<span class='kw'>end</span></pre>
|
300
|
+
</td>
|
301
|
+
</tr>
|
302
|
+
</table>
|
303
|
+
</div>
|
304
|
+
|
305
|
+
</div>
|
144
306
|
|
145
307
|
</div>
|
146
308
|
|
147
309
|
<div id="footer">
|
148
|
-
Generated on
|
310
|
+
Generated on Tue Apr 16 10:49:55 2013 by
|
149
311
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
150
|
-
0.8.
|
312
|
+
0.8.5 (ruby-1.9.3).
|
151
313
|
</div>
|
152
314
|
|
153
315
|
</body>
|