mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 20:02:38 +09:00
F #4913: Fix vCenter client for Ruby 2.4 (crypt token must be 32bytes)
This commit is contained in:
1 parent
42c03f918c
commit
6214e6e9b5
2 files changed
+25
-15
No files matched your search
@@ -39,12 +39,13 @@ class OpenNebula::ServerCipherAuth
|
||||
@srv_passwd = srv_passwd
|
||||
|
||||
if !srv_passwd.empty?
|
||||
@key = Digest::SHA1.hexdigest(@srv_passwd)
|
||||
# truncate token to 32-bytes for Ruby >= 2.4
|
||||
@key = Digest::SHA1.hexdigest(@srv_passwd)[0..31]
|
||||
else
|
||||
@key = ""
|
||||
end
|
||||
|
||||
@cipher = OpenSSL::Cipher::Cipher.new(CIPHER)
|
||||
@cipher = OpenSSL::Cipher.new(CIPHER)
|
||||
end
|
||||
|
||||
###########################################################################
|
||||
@@ -109,7 +110,8 @@ class OpenNebula::ServerCipherAuth
|
||||
# auth method for auth_mad
|
||||
def authenticate(srv_user,srv_pass, signed_text)
|
||||
begin
|
||||
@key = srv_pass
|
||||
# truncate token to 32-bytes for Ruby >= 2.4
|
||||
@key = srv_pass[0..31]
|
||||
|
||||
s_user, t_user, expires = decrypt(signed_text).split(':')
|
||||
|
||||
|
||||
@@ -56,27 +56,35 @@ class VIClient
|
||||
|
||||
token = config["ONE_KEY"]
|
||||
|
||||
begin
|
||||
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
|
||||
|
||||
cipher.decrypt
|
||||
cipher.key = token
|
||||
|
||||
password = cipher.update(Base64::decode64(password))
|
||||
password << cipher.final
|
||||
rescue
|
||||
puts "Error decrypting vCenter password"
|
||||
exit -1
|
||||
end
|
||||
password = VIClient::decrypt(password, token)
|
||||
|
||||
connection = {
|
||||
:host => host["TEMPLATE/VCENTER_HOST"],
|
||||
:user => host["TEMPLATE/VCENTER_USER"],
|
||||
:rp => host["TEMPLATE/VCENTER_RESOURCE_POOL"],
|
||||
:password => password
|
||||
}
|
||||
|
||||
self.new(connection)
|
||||
end
|
||||
|
||||
def self.decrypt(msg, token)
|
||||
begin
|
||||
cipher = OpenSSL::Cipher.new("aes-256-cbc")
|
||||
|
||||
cipher.decrypt
|
||||
|
||||
# Truncate for Ruby 2.4 (in previous versions this was being
|
||||
# automatically truncated)
|
||||
cipher.key = token[0..31]
|
||||
|
||||
msg = cipher.update(Base64::decode64(msg))
|
||||
msg << cipher.final
|
||||
rescue
|
||||
puts "Error decrypting secret."
|
||||
exit -1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end # module VCenterDriver
|
||||
Reference in new issue
Block a user