Skip to content

Commit

Permalink
pkey: prefer PKey.read over PKey::RSA.new in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenium committed May 13, 2020
1 parent 867e5c0 commit cf92a3f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ext/openssl/ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion sample/echo_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion sample/echo_svr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

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
Expand Down
2 changes: 1 addition & 1 deletion sample/gen_csr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def usage

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
Expand Down
2 changes: 1 addition & 1 deletion sample/smime_read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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)

Expand Down
2 changes: 1 addition & 1 deletion sample/smime_write.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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"
Expand Down

0 comments on commit cf92a3f

Please sign in to comment.