summaryrefslogtreecommitdiff
path: root/test/test_known_hosts.rb
diff options
context:
space:
mode:
authorSimon Chopin <simon.chopin@canonical.com>2022-04-08 09:32:24 +0200
committerFlorian Wininger <fw.centrale@gmail.com>2022-04-29 14:42:49 +0200
commit406063de2852cabe7d123c9dd72a72c4cfff8215 (patch)
treeee7c7daf619c60e8f453d822cc50d84a72ee6f70 /test/test_known_hosts.rb
parente4ffdc07b1f0f01ebeab359c1001984912d87437 (diff)
downloadnet-ssh-406063de2852cabe7d123c9dd72a72c4cfff8215.tar.gz
buffer: create RSA keys by loading PEM data directly
The OpenSSL 3.0 changes don't allow for us to modify the private key details directly, and there are no dedicated constructors as of Ruby 3.0, so we need to actually create a PEM certificate in-memory and load that instead. Co-authored-by: Lucas Kanashiro <lucas.kanashiro@canonical.com>
Diffstat (limited to 'test/test_known_hosts.rb')
-rw-r--r--test/test_known_hosts.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/test/test_known_hosts.rb b/test/test_known_hosts.rb
index f960351..e47e75b 100644
--- a/test/test_known_hosts.rb
+++ b/test/test_known_hosts.rb
@@ -166,13 +166,12 @@ class TestKnownHosts < NetSSHTest
end
def rsa_key
- key = OpenSSL::PKey::RSA.new
- if key.respond_to?(:set_key)
- key.set_key(0x7766554433221100, 0xffeeddccbbaa9988, nil)
- else
- key.e = 0xffeeddccbbaa9988
- key.n = 0x7766554433221100
- end
- key
+ n = 0x7766554433221100
+ e = 0xffeeddccbbaa9988
+ asn1 = OpenSSL::ASN1::Sequence([
+ OpenSSL::ASN1::Integer(n),
+ OpenSSL::ASN1::Integer(e)
+ ])
+ OpenSSL::PKey::RSA.new(asn1.to_der)
end
end