aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-03-22 03:51:24 +0900
committerKazuki Yamaguchi <k@rhe.jp>2020-05-13 16:14:06 +0900
commitcf92a3ffba6e5e588540e88c0be7db60cf774572 (patch)
tree43f6c49274a2f365bc4c8f28c59b7b20a009b92a
parent867e5c021b7308fe35612510c619b2bba424c184 (diff)
downloadruby-openssl-cf92a3ffba6e5e588540e88c0be7db60cf774572.tar.gz
pkey: prefer PKey.read over PKey::RSA.new in docs
-rw-r--r--ext/openssl/ossl.c6
-rw-r--r--sample/echo_cli.rb2
-rw-r--r--sample/echo_svr.rb2
-rw-r--r--sample/gen_csr.rb2
-rw-r--r--sample/smime_read.rb2
-rw-r--r--sample/smime_write.rb2
6 files changed, 8 insertions, 8 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 2f54b861..ab418764 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -679,13 +679,13 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
*
* A key can also be loaded from a file.
*
- * key2 = OpenSSL::PKey::RSA.new File.read 'private_key.pem'
+ * key2 = OpenSSL::PKey.read File.read 'private_key.pem'
* key2.public? # => true
* key2.private? # => true
*
* or
*
- * key3 = OpenSSL::PKey::RSA.new File.read 'public_key.pem'
+ * key3 = OpenSSL::PKey.read File.read 'public_key.pem'
* key3.public? # => true
* key3.private? # => false
*
@@ -697,7 +697,7 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
*
* key4_pem = File.read 'private.secure.pem'
* pass_phrase = 'my secure pass phrase goes here'
- * key4 = OpenSSL::PKey::RSA.new key4_pem, pass_phrase
+ * key4 = OpenSSL::PKey.read key4_pem, pass_phrase
*
* == RSA Encryption
*
diff --git a/sample/echo_cli.rb b/sample/echo_cli.rb
index 069a21ec..3fbadf33 100644
--- a/sample/echo_cli.rb
+++ b/sample/echo_cli.rb
@@ -15,7 +15,7 @@ ca_path = options["C"]
ctx = OpenSSL::SSL::SSLContext.new()
if cert_file && key_file
ctx.cert = OpenSSL::X509::Certificate.new(File::read(cert_file))
- ctx.key = OpenSSL::PKey::RSA.new(File::read(key_file))
+ ctx.key = OpenSSL::PKey.read(File::read(key_file))
end
if ca_path
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
diff --git a/sample/echo_svr.rb b/sample/echo_svr.rb
index ba15394e..1cc07b9b 100644
--- a/sample/echo_svr.rb
+++ b/sample/echo_svr.rb
@@ -13,7 +13,7 @@ ca_path = options["C"]
if cert_file && key_file
cert = OpenSSL::X509::Certificate.new(File::read(cert_file))
- key = OpenSSL::PKey::RSA.new(File::read(key_file))
+ key = OpenSSL::PKey.read(File::read(key_file))
else
key = OpenSSL::PKey::RSA.new(512){ print "." }
puts
diff --git a/sample/gen_csr.rb b/sample/gen_csr.rb
index a061260c..2602b68a 100644
--- a/sample/gen_csr.rb
+++ b/sample/gen_csr.rb
@@ -25,7 +25,7 @@ name = X509::Name.parse(name_str)
keypair = nil
if keypair_file
- keypair = PKey::RSA.new(File.open(keypair_file).read)
+ keypair = PKey.read(File.read(keypair_file))
else
keypair = PKey::RSA.new(1024) { putc "." }
puts
diff --git a/sample/smime_read.rb b/sample/smime_read.rb
index 17394f9b..a70105fd 100644
--- a/sample/smime_read.rb
+++ b/sample/smime_read.rb
@@ -11,7 +11,7 @@ ca_path = options["C"]
data = $stdin.read
cert = X509::Certificate.new(File::read(cert_file))
-key = PKey::RSA.new(File::read(key_file))
+key = PKey::read(File::read(key_file))
p7enc = PKCS7::read_smime(data)
data = p7enc.decrypt(key, cert)
diff --git a/sample/smime_write.rb b/sample/smime_write.rb
index 5a5236c7..20c933b2 100644
--- a/sample/smime_write.rb
+++ b/sample/smime_write.rb
@@ -9,7 +9,7 @@ key_file = options["k"]
rcpt_file = options["r"]
cert = X509::Certificate.new(File::read(cert_file))
-key = PKey::RSA.new(File::read(key_file))
+key = PKey::read(File::read(key_file))
data = "Content-Type: text/plain\r\n"
data << "\r\n"