njh / ruby-mqtt

Pure Ruby gem that implements the MQTT protocol, a lightweight protocol for publish/subscribe messaging.
http://www.rubydoc.info/gems/mqtt
MIT License
542 stars 135 forks source link

Error OpenSSL alert unknown ca #126

Closed darlandieterich closed 1 year ago

darlandieterich commented 3 years ago

When connect show this error: OpenSSL Error[0]: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca

My params:

data = {
      :host => "localhost",
      :port => 8883,
      :username => "someone",
      :password => "anyonecanenterhere",
      :ssl => true,
      :cert_file => '/app/cert/mosq_serv.crt',
      :key_file => '/app/cert/mosq_serv.key',
      :ca_file => '/app/cert/mosq_ca.crt'
    }

My mosquitto .config:

listener 8883
allow_anonymous false
password_file /app/passwordfile.pwd
cafile /app/cert/mosq_ca.crt
certfile /app/cert/mosq_serv.crt
keyfile /app/cert/mosq_serv.key
protocol mqtt
tls_version tlsv1.2
require_certificate true

My question is, it's valid to only .pem?

njh commented 3 years ago

Just checked and the Cert file and key file are passed into OpenSSL::X509::Certificate and OpenSSL::PKey::RSA respectively:

Docs are here:

They say: