summaryrefslogtreecommitdiff
path: root/sample/openssl/gen_csr.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2021-02-25 16:49:11 +0900
committerKazuki Yamaguchi <k@rhe.jp>2021-03-16 19:37:06 +0900
commite35d3623de47b1a8d699f431460fbcba36de84f2 (patch)
treeea4c2e2e6a9911e52b9ba16a2efd58e5259ba7d8 /sample/openssl/gen_csr.rb
parenta3f97007bbd1012a4b7662b8166118b81b52527a (diff)
[ruby/openssl] sample: avoid "include OpenSSL"
It is not a common practice and should not be done since it causes name clash: for example, Digest and Random are provided by other standard libraries of Ruby. Fixes: https://github.com/ruby/openssl/issues/419 https://github.com/ruby/openssl/commit/6a6444984b
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4275
Diffstat (limited to 'sample/openssl/gen_csr.rb')
-rw-r--r--sample/openssl/gen_csr.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/sample/openssl/gen_csr.rb b/sample/openssl/gen_csr.rb
index 2602b68a11..baac9905be 100644
--- a/sample/openssl/gen_csr.rb
+++ b/sample/openssl/gen_csr.rb
@@ -3,8 +3,6 @@
require 'optparse'
require 'openssl'
-include OpenSSL
-
def usage
myname = File::basename($0)
$stderr.puts <<EOS
@@ -21,13 +19,13 @@ keyout = options["keyout"] || "keypair.pem"
$stdout.sync = true
name_str = ARGV.shift or usage()
-name = X509::Name.parse(name_str)
+name = OpenSSL::X509::Name.parse(name_str)
keypair = nil
if keypair_file
- keypair = PKey.read(File.read(keypair_file))
+ keypair = OpenSSL::PKey.read(File.read(keypair_file))
else
- keypair = PKey::RSA.new(1024) { putc "." }
+ keypair = OpenSSL::PKey::RSA.new(1024) { putc "." }
puts
puts "Writing #{keyout}..."
File.open(keyout, "w", 0400) do |f|
@@ -37,7 +35,7 @@ end
puts "Generating CSR for #{name_str}"
-req = X509::Request.new
+req = OpenSSL::X509::Request.new
req.version = 0
req.subject = name
req.public_key = keypair.public_key