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
This commit is contained in:
Marc Herbert 2018-12-04 18:10:41 -08:00
parent 56779ebe21
commit d41f5d7d0a
1 changed files with 2 additions and 2 deletions

View File

@ -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()