core: retry SSH keygen on RSAError [GH-5056]
/cc @sethvargo
This commit is contained in:
parent
bb25bb3be9
commit
79115d1ccc
|
@ -49,6 +49,7 @@ BUG FIXES:
|
|||
- core: Only take files when packaging a box to avoid duplicates [GH-5658, GH-5657]
|
||||
- core: escape curl urls and authentication [GH-5677]
|
||||
- core: fix crash if a value is missing for CLI arguments [GH-5550]
|
||||
- core: retry SSH key generation for transient RSA errors [GH-5056]
|
||||
- core/cli: fix box checksum validation [GH-4665, GH-5221]
|
||||
- core/windows: allow Windows UNC paths to allow more than 256
|
||||
characters [GH-4815]
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
require "base64"
|
||||
require "openssl"
|
||||
|
||||
require "vagrant/util/retryable"
|
||||
|
||||
module Vagrant
|
||||
module Util
|
||||
class Keypair
|
||||
extend Retryable
|
||||
|
||||
# Creates an SSH keypair and returns it.
|
||||
#
|
||||
# @param [String] password Password for the key, or nil for no password.
|
||||
|
@ -11,7 +15,13 @@ module Vagrant
|
|||
# respectively. The final element is the OpenSSH encoded public
|
||||
# key.
|
||||
def self.create(password=nil)
|
||||
# This sometimes fails with RSAError. It is inconsistent and strangely
|
||||
# sleeps seem to fix it. We just retry this a few times. See GH-5056
|
||||
rsa_key = nil
|
||||
retryable(on: OpenSSL::PKey::RSAError, sleep: 2, tries: 5) do
|
||||
rsa_key = OpenSSL::PKey::RSA.new(2048)
|
||||
end
|
||||
|
||||
public_key = rsa_key.public_key
|
||||
private_key = rsa_key.to_pem
|
||||
|
||||
|
|
Loading…
Reference in New Issue