ruby-changes:65565
From: Kazuki <ko1@a...>
Date: Tue, 16 Mar 2021 20:39:03 +0900 (JST)
Subject: [ruby-changes:65565] 7f0b3fb906 (master): [ruby/openssl] sample: update obsolete API use
https://git.ruby-lang.org/ruby.git/commit/?id=7f0b3fb906 From 7f0b3fb9060b75b4f15b8e7e5866d2c13c132c29 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi <k@r...> Date: Thu, 25 Feb 2021 16:55:40 +0900 Subject: [ruby/openssl] sample: update obsolete API use https://github.com/ruby/openssl/commit/dafa851c0d --- sample/openssl/c_rehash.rb | 3 +-- sample/openssl/echo_svr.rb | 6 +++--- sample/openssl/gen_csr.rb | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sample/openssl/c_rehash.rb b/sample/openssl/c_rehash.rb index 8282816..de4b66e 100644 --- a/sample/openssl/c_rehash.rb +++ b/sample/openssl/c_rehash.rb @@ -1,7 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/sample/openssl/c_rehash.rb#L1 #!/usr/bin/env ruby require 'openssl' -require 'digest/md5' class CHashDir include Enumerable @@ -161,7 +160,7 @@ private https://github.com/ruby/ruby/blob/trunk/sample/openssl/c_rehash.rb#L160 end def fingerprint(der) - Digest.hexdigest('MD5', der).upcase + OpenSSL::Digest.hexdigest('MD5', der).upcase end end diff --git a/sample/openssl/echo_svr.rb b/sample/openssl/echo_svr.rb index 1cc07b9..f20fb52 100644 --- a/sample/openssl/echo_svr.rb +++ b/sample/openssl/echo_svr.rb @@ -15,7 +15,7 @@ if cert_file && key_file https://github.com/ruby/ruby/blob/trunk/sample/openssl/echo_svr.rb#L15 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 https://github.com/ruby/ruby/blob/trunk/sample/openssl/echo_svr.rb#L25 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 https://github.com/ruby/ruby/blob/trunk/sample/openssl/echo_svr.rb#L37 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() diff --git a/sample/openssl/gen_csr.rb b/sample/openssl/gen_csr.rb index baac990..34b23fe 100644 --- a/sample/openssl/gen_csr.rb +++ b/sample/openssl/gen_csr.rb @@ -25,7 +25,7 @@ keypair = nil https://github.com/ruby/ruby/blob/trunk/sample/openssl/gen_csr.rb#L25 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}" https://github.com/ruby/ruby/blob/trunk/sample/openssl/gen_csr.rb#L38 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| -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/