From d41f5d7d0add987255db22b4189807a28e3e71ee Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 4 Dec 2018 18:10:41 -0800 Subject: [PATCH] tests/__init__.py: ssh-keygen -m PEM for bouncycastle From: https://www.openssh.com/txt/release-7.8 change log: * ssh-keygen(1): write OpenSSH format private keys by default instead of using OpenSSL's PEM format. The OpenSSH format, supported in OpenSSH releases since 2014 and described in the PROTOCOL.key file in the source distribution, offers substantially better protection against offline password guessing and supports key comments in private keys. If necessary, it is possible to write old PEM-style keys by adding "-m PEM" to ssh-keygen's arguments when generating or updating a key. This fixes all tests failing with this error: [2018-12-04 17:46:24,130] WARN org.apache.sshd.common.keyprovider.FileKeyPairProvider : Unable to read key /home/mherber2/pip/src/git-review/.gerrit/site-5123/etc/ssh_host_rsa_key java.io.IOException: unrecognised object: OPENSSH PRIVATE KEY at org.bouncycastle.openssl.PEMParser.readObject(Unknown Source) at org.apache.sshd.common.keyprovider.FileKeyPairProvider.doLoadKey(FileKeyPairProvider.java:124) Change-Id: Id10f9b5be928f2ba57847fa32814e9db979375f5 --- git_review/tests/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git_review/tests/__init__.py b/git_review/tests/__init__.py index d00cd749..128aae6e 100644 --- a/git_review/tests/__init__.py +++ b/git_review/tests/__init__.py @@ -153,7 +153,7 @@ class GerritHelpers(DirHelpers): os.makedirs(self._dir('gsite', 'etc')) # create SSH host key host_key_file = self._dir('gsite', 'etc', 'ssh_host_rsa_key') - utils.run_cmd('ssh-keygen', '-t', 'rsa', '-b', '4096', + utils.run_cmd('ssh-keygen', '-t', 'rsa', '-b', '4096', '-m', 'PEM', '-f', host_key_file, '-N', '') print("Creating a new golden site of version " + GOLDEN_SITE_VER) @@ -171,7 +171,7 @@ class GerritHelpers(DirHelpers): # create SSH public key key_file = self._dir('gsite', 'test_ssh_key') - utils.run_cmd('ssh-keygen', '-t', 'rsa', '-b', '4096', + utils.run_cmd('ssh-keygen', '-t', 'rsa', '-b', '4096', '-m', 'PEM', '-f', key_file, '-N', '') with open(key_file + '.pub', 'rb') as pub_key_file: pub_key = pub_key_file.read()