In a self-hosted setup using Discourse with FusionAuth for OAuth2 authentication, danchik encountered an SSL certificate verification error after OAuth2 callback: Faraday::SSLError (unable to get local issuer certificate). The issue arose because Discourse’s Ruby runtime attempted to verify the certificate when fetching user info post-authentication, even though both services are behind an Nginx proxy handling SSL termination. robotdan suggested checking if the redirect URL in FusionAuth uses https, verifying certificate trust (especially for self-signed certs), or switching to Let’s Encrypt. He also asked if danchik tried OpenID Connect as an alternative. Ultimately, danchik resolved the issue by embedding the intermediate certificate directly into /usr/lib/ssh/cert.pem inside the Discourse container via app.yaml, since he couldn’t find a way to mount an external cert file during the ./launcher rebuild app step. The fix bypassed the Ruby SSL verification failure by ensuring the local cert store trusted the issuer.
I am having certificate issue (looks like right after call back returns from oauth2). Discourse and fusionauth are both behind nginx that listens on 443 and proxies to both via http, and fusionauth is the authenticator that discourse uses (with the discourse-basic-oauth2 plugin)
A call to oauth2 goes to fusionauth, but when the redirect url comes back discord throws error:
Faraday::SSLError (SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)) /usr/local/lib/ruby/2.5.0/net/protocol.rb:44:in connect_nonblock
technically nginx is the only ssl entry, and proxies to both servers on http… but I am assuming discourse is trying to maybe issue requests to pull user info down, maybe, using curl direct, and that what is throwing the error? Do I need to get inside discourse container and update certs inside (though im at latest discourse version already and system certs are up to date)
Have you read through this thread, seems like a similar issue.
Assuming this is an Nginx or Discourse configuration issue, but in case FusionAuth is contributing to the issue I’ll offer any help that I can.
It looks like you’re using a self signed certificate, which is ok, but you likely need to add that to your local certificate store. Alternatively you could use Let’s Encrypt so you don’t need to deal with managing a self signed certificate.
Have you tried to recreate with an OpenID Connect plugin in addition to the discourse-basic-oauth2 plugin?
Since both FusionAuth and Discourse are behind the proxy, have you configured your redirect in FusionAuth to use https or http?
If you have any other questions on the FusionAuth configuration I’m happy to help.
It was the ruby trying to verify peer cert when getting the token and user info after being authorized.
I ended up adding the intermediate cert for our server directly into /usr/lib/ssh/cert.pem via app.yaml
-file:
path: /usr/lib/ssh/cert.pem
contents: |
------ the cert part.....
though i originally wanted to just copy it from outside into container at the ./launcher rebuild app step but I couldn’t find a way to refer to external file inside app.yaml