Home > Enterprise >  Viewport not connecting in Ubuntu Server VM
Viewport not connecting in Ubuntu Server VM

Time:06-16

I am migrating a Redmine plugin that implements user authentication via EWS. The plugin was tested on Redmine v4.x running on an Ubuntu Desktop VM and was working correctly (could tell if the given credentials were valid or not).

The main part of the plugin is:

require 'viewpoint'
include Viewpoint::EWS

defaultServer      = 'https://company.mail.server/ews/exchange.asmx'
defaultEmailDomain = '@domain.com'

emailAddress = "username"   defaultEmailDomain
password     = "password"

client = Viewpoint::EWSClient.new(defaultServer, emailAddress, password)
result = client

begin
    client.folders
rescue
    result = 'nope'
end

puts result

This code works on both the previous VM and my Windows machine, but on my new Ubuntu Server 22.04 VM returns 'nope'.

I also tried to write a version in Python using exchangelib, which worked on the new VM. IMO that indicates that the problem is not related to any network constrictions Ubuntu Server might have.

Any suggestions?

Update:

Following Richard's suggestion I saved the error message captured by rescue. After changing the error type to EwsError, I got the following:

/usr/lib/ruby/3.0.0/openssl/digest.rb:35:in `initialize': Digest initialization failed: initialization error (OpenSSL::Digest::DigestError)
    from /usr/lib/ruby/3.0.0/openssl/digest.rb:35:in `block (3 levels) in <class:Digest>'
    from /usr/lib/ruby/3.0.0/openssl/digest.rb:41:in `new'
    from /usr/lib/ruby/3.0.0/openssl/digest.rb:41:in `block (3 levels) in <class:Digest>'
    from /var/lib/gems/3.0.0/gems/rubyntlm-0.6.3/lib/net/ntlm.rb:149:in `ntlm_hash'
    from /var/lib/gems/3.0.0/gems/rubyntlm-0.6.3/lib/net/ntlm.rb:162:in `ntlmv2_hash'
    from /var/lib/gems/3.0.0/gems/rubyntlm-0.6.3/lib/net/ntlm/message/type2.rb:73:in `response'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:563:in `block in get'
    from /usr/lib/ruby/3.0.0/mutex_m.rb:78:in `synchronize'
    from /usr/lib/ruby/3.0.0/mutex_m.rb:78:in `mu_synchronize'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:537:in `get'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:97:in `block in filter_request'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:95:in `each'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:95:in `filter_request'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1231:in `block in do_get_block'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1230:in `each'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1230:in `do_get_block'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1019:in `block in do_request'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1133:in `protect_keep_alive_disconnected'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1014:in `do_request'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:856:in `request'
    from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:765:in `post'
    from /var/lib/gems/3.0.0/gems/viewpoint-1.1.1/lib/ews/connection.rb:103:in `post'
    from /var/lib/gems/3.0.0/gems/viewpoint-1.1.1/lib/ews/connection.rb:81:in `dispatch'
    from /var/lib/gems/3.0.0/gems/viewpoint-1.1.1/lib/ews/soap/exchange_web_service.rb:212:in `do_soap_request'
    from /var/lib/gems/3.0.0/gems/viewpoint-1.1.1/lib/ews/soap/exchange_data_services.rb:503:in `find_folder'
    from /var/lib/gems/3.0.0/gems/viewpoint-1.1.1/lib/ews/folder_accessors.rb:45:in `folders'
    from /home/jdredd/auth_source_ews/app/models/test.rb:27:in `<main>'

Additional info: the Windows test machine, where the user authentication runs succesfully, has the same gem versions as above. The only difference is the verion of Ruby itself (3.0.2p107 on Ubuntu, 3.1.2p20 on Windows).

Update:

After modifying openssl.cnf according to this diff enabling loading legacy providers, the plugin works now.

CodePudding user response:

Try investigating the error message.

begin
    client.folders
rescue StandardError => err
    puts err
    result = 'nope'
end

https://thoughtbot.com/blog/rescue-standarderror-not-exception

  • Related