Skip to content

Issues verifying certificate connecting with HTTPS #5266

Closed
@theodorton

Description

Crystal version

~/code/nabobil/autotoll · (master±)
⟩ crystal -v
Crystal 0.23.1 (2017-10-12) LLVM 4.0.1

How to reproduce

# test.cr
require "http/client"

client = HTTP::Client.new("maps.googleapis.com", tls: true)
client.get "/"

Then run crystal run test.cr.

Expected outcome

No errors raised, or some redirect.

Actual outcome

SSL_connect: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed (OpenSSL::SSL::Error)
0x10d990e45: *CallStack::unwind:Array(Pointer(Void)) at ??
0x10d990de1: *CallStack#initialize:Array(Pointer(Void)) at ??
0x10d990db8: *CallStack::new:CallStack at ??
0x10d98d615: *raise<OpenSSL::SSL::Error>:NoReturn at ??
0x10da33571: *OpenSSL::SSL::Socket::Client#initialize<TCPSocket, OpenSSL::SSL::Context::Client, Bool, String>:Nil at ??
0x10da333ec: *OpenSSL::SSL::Socket::Client::new:context:sync_close:hostname<TCPSocket, OpenSSL::SSL::Context::Client, Bool, String>:OpenSSL::SSL::Socket::Client at ??
0x10da29c91: *HTTP::Client#socket:(OpenSSL::SSL::Socket+ | TCPSocket+) at ??
0x10da299eb: *HTTP::Client#exec_internal_single<HTTP::Request>:(HTTP::Client::Response | Nil) at ??
0x10da26f7c: *HTTP::Client#exec_internal<HTTP::Request>:HTTP::Client::Response at ??
0x10da26e72: *HTTP::Client#exec<HTTP::Request>:HTTP::Client::Response at ??
0x10da26bdd: *HTTP::Client#exec<String, String, Nil, Nil>:HTTP::Client::Response at ??
0x10da26bb7: *HTTP::Client#get<String>:HTTP::Client::Response at ??
0x10d97bcba: __crystal_main at ??
0x10d98c678: main at ??

Notes

  • This also happens when running the code within the official docker image for 0.23.1.
  • I've managed to get it to pass randomly, but I believe there is some cipher requirement and that the certificates differ somewhat between the servers behind this domain
  • When running openssl s_client -connect maps.googleapis.com:443 -tls1_2 I get:
CONNECTED(00000003)
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify return:1
depth=1 C = US, O = Google Inc, CN = Google Internet Authority G2
verify return:1
depth=0 C = US, ST = California, L = Mountain View, O = Google Inc, CN = *.googleapis.com
verify return:1
---
...
...
  • It works if I setup a similar example in Ruby:
require 'net/http'
require 'uri'

uri = URI('https://maps.googleapis.com/')

Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
  request = Net::HTTP::Get.new uri
  response = http.request request # Net::HTTPResponse object
  puts response
end
  • In other words, I don't believe this is an issue with my openssl configuration.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions