Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ gem 'sequel', '~> 5.75'
gem 'sequel_pg', require: 'sequel'
gem 'sinatra', '~> 3.1'
gem 'sinatra-contrib'
gem 'sshkey'
gem 'statsd-ruby', '~> 1.5.0'
gem 'steno'
gem 'talentbox-delayed_job_sequel', '~> 4.3.0'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ GEM
spring (4.1.3)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
sshkey (3.0.0)
statsd-ruby (1.5.0)
steno (1.3.4)
fluent-logger
Expand Down Expand Up @@ -651,6 +652,7 @@ DEPENDENCIES
spork!
spring
spring-commands-rspec
sshkey
statsd-ruby (~> 1.5.0)
steno
talentbox-delayed_job_sequel (~> 4.3.0)
Expand Down
7 changes: 5 additions & 2 deletions lib/cloud_controller/diego/ssh_key.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
require 'net/ssh'
require 'sshkey'

module VCAP
module CloudController
module Diego
class SSHKey
def initialize(bits=1024)
def initialize(bits=2048)
@bits = bits
end

Expand All @@ -21,7 +22,9 @@ def authorized_key
end
end

delegate :fingerprint, to: :key
def fingerprint
@fingerprint ||= ::SSHKey.new(key.to_der).sha1_fingerprint
end

private

Expand Down
7 changes: 7 additions & 0 deletions spec/unit/lib/cloud_controller/diego/ssh_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ module Diego
expect(key1).to eq(key2)
end
end

describe '#fingerprint' do
it 'returns an sha1 fingerprint' do
ssh_key = SSHKey.new(1024)
expect(ssh_key.fingerprint).to match(/([0-9a-f]{2}:){19}[0-9a-f]{2}/)
end
end
end
end
end