Skip to content

Commit dafa851

Browse files
committed
sample: update obsolete API use
1 parent 6a64449 commit dafa851

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

sample/c_rehash.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env ruby
22

33
require 'openssl'
4-
require 'digest/md5'
54

65
class CHashDir
76
include Enumerable
@@ -161,7 +160,7 @@ def hash_name(name)
161160
end
162161

163162
def fingerprint(der)
164-
Digest.hexdigest('MD5', der).upcase
163+
OpenSSL::Digest.hexdigest('MD5', der).upcase
165164
end
166165
end
167166

sample/echo_svr.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
cert = OpenSSL::X509::Certificate.new(File::read(cert_file))
1616
key = OpenSSL::PKey.read(File::read(key_file))
1717
else
18-
key = OpenSSL::PKey::RSA.new(512){ print "." }
18+
key = OpenSSL::PKey::RSA.new(2048){ print "." }
1919
puts
2020
cert = OpenSSL::X509::Certificate.new
2121
cert.version = 2
@@ -25,7 +25,7 @@
2525
cert.issuer = name
2626
cert.not_before = Time.now
2727
cert.not_after = Time.now + 3600
28-
cert.public_key = key.public_key
28+
cert.public_key = key
2929
ef = OpenSSL::X509::ExtensionFactory.new(nil,cert)
3030
cert.extensions = [
3131
ef.create_extension("basicConstraints","CA:FALSE"),
@@ -37,7 +37,7 @@
3737
ef.issuer_certificate = cert
3838
cert.add_extension ef.create_extension("authorityKeyIdentifier",
3939
"keyid:always,issuer:always")
40-
cert.sign(key, OpenSSL::Digest.new('SHA1'))
40+
cert.sign(key, "SHA1")
4141
end
4242

4343
ctx = OpenSSL::SSL::SSLContext.new()

sample/gen_csr.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def usage
2525
if keypair_file
2626
keypair = OpenSSL::PKey.read(File.read(keypair_file))
2727
else
28-
keypair = OpenSSL::PKey::RSA.new(1024) { putc "." }
28+
keypair = OpenSSL::PKey::RSA.new(2048) { putc "." }
2929
puts
3030
puts "Writing #{keyout}..."
3131
File.open(keyout, "w", 0400) do |f|
@@ -38,8 +38,8 @@ def usage
3838
req = OpenSSL::X509::Request.new
3939
req.version = 0
4040
req.subject = name
41-
req.public_key = keypair.public_key
42-
req.sign(keypair, Digest.new('MD5'))
41+
req.public_key = keypair
42+
req.sign(keypair, "MD5")
4343

4444
puts "Writing #{csrout}..."
4545
File.open(csrout, "w") do |f|

0 commit comments

Comments
 (0)