Skip to content

Commit 9941def

Browse files
authored
Bump default key length to 2048 and change fingerprint to SHA1 (#3555)
1 parent a5ef349 commit 9941def

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ gem 'sequel', '~> 5.75'
4040
gem 'sequel_pg', require: 'sequel'
4141
gem 'sinatra', '~> 3.1'
4242
gem 'sinatra-contrib'
43+
gem 'sshkey'
4344
gem 'statsd-ruby', '~> 1.5.0'
4445
gem 'steno'
4546
gem 'talentbox-delayed_job_sequel', '~> 4.3.0'

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ GEM
527527
spring (4.1.3)
528528
spring-commands-rspec (1.0.4)
529529
spring (>= 0.9.1)
530+
sshkey (3.0.0)
530531
statsd-ruby (1.5.0)
531532
steno (1.3.4)
532533
fluent-logger
@@ -651,6 +652,7 @@ DEPENDENCIES
651652
spork!
652653
spring
653654
spring-commands-rspec
655+
sshkey
654656
statsd-ruby (~> 1.5.0)
655657
steno
656658
talentbox-delayed_job_sequel (~> 4.3.0)

lib/cloud_controller/diego/ssh_key.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
require 'net/ssh'
2+
require 'sshkey'
23

34
module VCAP
45
module CloudController
56
module Diego
67
class SSHKey
7-
def initialize(bits=1024)
8+
def initialize(bits=2048)
89
@bits = bits
910
end
1011

@@ -21,7 +22,9 @@ def authorized_key
2122
end
2223
end
2324

24-
delegate :fingerprint, to: :key
25+
def fingerprint
26+
@fingerprint ||= ::SSHKey.new(key.to_der).sha1_fingerprint
27+
end
2528

2629
private
2730

spec/unit/lib/cloud_controller/diego/ssh_key_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ module Diego
3232
expect(key1).to eq(key2)
3333
end
3434
end
35+
36+
describe '#fingerprint' do
37+
it 'returns an sha1 fingerprint' do
38+
ssh_key = SSHKey.new(1024)
39+
expect(ssh_key.fingerprint).to match(/([0-9a-f]{2}:){19}[0-9a-f]{2}/)
40+
end
41+
end
3542
end
3643
end
3744
end

0 commit comments

Comments
 (0)