Skip to content

Commit

Permalink
sample: update obsolete API use
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenium committed Feb 25, 2021
1 parent 6a64449 commit dafa851
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions sample/c_rehash.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env ruby

require 'openssl'
require 'digest/md5'

class CHashDir
include Enumerable
Expand Down Expand Up @@ -161,7 +160,7 @@ def hash_name(name)
end

def fingerprint(der)
Digest.hexdigest('MD5', der).upcase
OpenSSL::Digest.hexdigest('MD5', der).upcase
end
end

Expand Down
6 changes: 3 additions & 3 deletions sample/echo_svr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
cert = OpenSSL::X509::Certificate.new(File::read(cert_file))
key = OpenSSL::PKey.read(File::read(key_file))
else
key = OpenSSL::PKey::RSA.new(512){ print "." }
key = OpenSSL::PKey::RSA.new(2048){ print "." }
puts
cert = OpenSSL::X509::Certificate.new
cert.version = 2
Expand All @@ -25,7 +25,7 @@
cert.issuer = name
cert.not_before = Time.now
cert.not_after = Time.now + 3600
cert.public_key = key.public_key
cert.public_key = key
ef = OpenSSL::X509::ExtensionFactory.new(nil,cert)
cert.extensions = [
ef.create_extension("basicConstraints","CA:FALSE"),
Expand All @@ -37,7 +37,7 @@
ef.issuer_certificate = cert
cert.add_extension ef.create_extension("authorityKeyIdentifier",
"keyid:always,issuer:always")
cert.sign(key, OpenSSL::Digest.new('SHA1'))
cert.sign(key, "SHA1")
end

ctx = OpenSSL::SSL::SSLContext.new()
Expand Down
6 changes: 3 additions & 3 deletions sample/gen_csr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def usage
if keypair_file
keypair = OpenSSL::PKey.read(File.read(keypair_file))
else
keypair = OpenSSL::PKey::RSA.new(1024) { putc "." }
keypair = OpenSSL::PKey::RSA.new(2048) { putc "." }
puts
puts "Writing #{keyout}..."
File.open(keyout, "w", 0400) do |f|
Expand All @@ -38,8 +38,8 @@ def usage
req = OpenSSL::X509::Request.new
req.version = 0
req.subject = name
req.public_key = keypair.public_key
req.sign(keypair, Digest.new('MD5'))
req.public_key = keypair
req.sign(keypair, "MD5")

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

0 comments on commit dafa851

Please sign in to comment.