mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/openssl] sample: update obsolete API use
https://github.com/ruby/openssl/commit/dafa851c0d
This commit is contained in:
parent
e35d3623de
commit
7f0b3fb906
Notes:
git
2021-03-16 20:38:41 +09:00
3 changed files with 7 additions and 8 deletions
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'openssl'
|
||||
require 'digest/md5'
|
||||
|
||||
class CHashDir
|
||||
include Enumerable
|
||||
|
@ -161,7 +160,7 @@ private
|
|||
end
|
||||
|
||||
def fingerprint(der)
|
||||
Digest.hexdigest('MD5', der).upcase
|
||||
OpenSSL::Digest.hexdigest('MD5', der).upcase
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ if cert_file && key_file
|
|||
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
|
||||
|
@ -25,7 +25,7 @@ else
|
|||
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"),
|
||||
|
@ -37,7 +37,7 @@ else
|
|||
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()
|
||||
|
|
|
@ -25,7 +25,7 @@ keypair = nil
|
|||
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|
|
||||
|
@ -38,8 +38,8 @@ puts "Generating CSR for #{name_str}"
|
|||
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|
|
||||
|
|
Loading…
Add table
Reference in a new issue