Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

certificate verify failed (unable to get local issuer certificate) #1537

Closed
HarshRajIN opened this issue Dec 13, 2022 · 5 comments
Closed

certificate verify failed (unable to get local issuer certificate) #1537

HarshRajIN opened this issue Dec 13, 2022 · 5 comments

Comments

@HarshRajIN
Copy link

HarshRajIN commented Dec 13, 2022

Running into SSL issue while sending SMTP mail on version 2.8.0, while it works all fine with 2.7.1.

**SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)** 
	/usr/local/lib/ruby/2.6.0/net/protocol.rb:44:in 'connect_nonblock'
	/usr/local/lib/ruby/2.6.0/net/protocol.rb:44:in 'ssl_socket_connect'
	/usr/local/bundle/gems/net-smtp-0.3.3/lib/net/smtp.rb:690:in 'tlsconnect'
	/usr/local/bundle/gems/net-smtp-0.3.3/lib/net/smtp.rb:666:in 'do_start'
	/usr/local/bundle/gems/net-smtp-0.3.3/lib/net/smtp.rb:611:in 'start'
	/usr/local/bundle/gems/mail-2.8.0/lib/mail/network/delivery_methods/smtp.rb:109:in 'start_smtp_session'
	/usr/local/bundle/gems/mail-2.8.0/lib/mail/network/delivery_methods/smtp.rb:100:in 'deliver!'
	/usr/local/bundle/gems/mail-2.8.0/lib/mail/message.rb:269:in 'deliver!'
@HarshRajIN
Copy link
Author

Ruby 2.6.4

@eval
Copy link
Collaborator

eval commented Dec 13, 2022

@HarshRajIN what config did you use?

@HarshRajIN
Copy link
Author

def self.send_using_options(options, environment)
        options[:from] = 'no_reply@company.com'
        options[:via] = :smtp
        options[:via_options] = {
          address: smtp_server_address(environment),
          port: '25',
          domain: 'company.com'
        }
        Pony.mail(options)
      end

Log-

SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate) 
	/usr/local/lib/ruby/2.6.0/net/protocol.rb:44:in `connect_nonblock'
	/usr/local/lib/ruby/2.6.0/net/protocol.rb:44:in `ssl_socket_connect'
	/usr/local/bundle/gems/net-smtp-0.3.3/lib/net/smtp.rb:690:in `tlsconnect'
	/usr/local/bundle/gems/net-smtp-0.3.3/lib/net/smtp.rb:666:in `do_start'
	/usr/local/bundle/gems/net-smtp-0.3.3/lib/net/smtp.rb:611:in `start'
	/usr/local/bundle/gems/mail-2.8.0/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
	/usr/local/bundle/gems/mail-2.8.0/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
	/usr/local/bundle/gems/mail-2.8.0/lib/mail/message.rb:269:in `deliver!'
	/usr/local/bundle/gems/pony-1.13.1/lib/pony.rb:177:in `deliver'
	/usr/local/bundle/gems/pony-1.13.1/lib/pony.rb:166:in `mail'
	/usr/local/bundle/gems/cert-app-2.4.0/lib/cert_app/util/mail.rb:33:in `send_using_options'

@eval
Copy link
Collaborator

eval commented Dec 14, 2022

Newer versions of net-smtp will do starttls by default.

From mail v2.8 you can override this. Try

def self.send_using_options(options, environment)
        options[:from] = 'no_reply@company.com'
        options[:via] = :smtp
        options[:via_options] = {
          address: smtp_server_address(environment),
          port: '25',
<         domain: 'company.com'
>         domain: 'company.com',
>         enable_starttls: false
        }
        Pony.mail(options)
      end

NOTE: only use when you don't want to upgrade a non-secure connection.

@HarshRajIN
Copy link
Author

Got it. Thanks @eval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants