Auth0 Ruby on Rails TCP Error - ruby-on-rails

I am using Auth0's Ruby on Rails API Sample as boilerplate to set up authentication with a new app. Everything is working up to but not including the "Test Your API with cURL" step on the second page of the instructions.
I have tried testing both with cURL and with Postman, and both times I receive the follwoing error:
Errno::ECONNREFUSED in PrivateController#private. Failed to open TCP connection to :443 (Connection refused - connect(2) for nil port 443)
The highlighted line of the error is the following: jwks_raw = Net::HTTP.get URI("https://#{Rails.application.secrets.auth0_domain}/.well-known/jwks.json").
I receive the same error when I clone the sample repo directly and attempt testing with my Access Token, so it seems that it is possibly an oversight or outdated code in their example rather than some error with my incorporation of it into my own app.
How do I resolve this?

Make sure the auth0_domain secret is set when you are passing it to the rails app.
If the value is empty, it will make your initial string an invalid URL, i.e. "https://#{Rails.application.secrets.auth0_domain}/.well-known/jwks.json" turns into "https:///.well-known/jwks.json".
In my case I was using an empty environment variable, which returned nil:
ENV['AUTH0_DOMAIN']
=> nil
Hope this answer helps you!

Related

OAuth Error 400: invalid_request Missing scheme: /login

I am trying to use OAuth in my app and I am getting the following error after clicking the login button to be redirected to the generated url.
However, I am getting the following error but I'm pretty sure that I have my URI's configured correctly in the developers console (image below).
Also, I am not finding the same error while searching. Has anyone else encountered this?
I am pretty sure that I have the /login scheme configured correctly as so.
It's worth mentioning that I am following a tutorial series and this is exactly what they recommended. That's another reason I'm pretty confused.
Thanks for any help in advance.
I discovered the issue - I was passing an invalid URL into the options of google.auth.OAuth2( ... )
I failed to realize this because my URL was coming from .env file.

Are you trying to open an SSL connection to a non-SSL Puma?

After working on getting a new project to work, I found that for some reason I couldn't start my rails server. I kept getting the following error:
HTTP parse error, malformed request: #<Puma::HttpParserError: Invalid HTTP format, parsing fails. Are you trying to open an SSL connection to a non-SSL Puma?>
I was able to solve this problem by clearing my browsing history, cookies and saved images.
Click ...
More tools
Clear Browsing Data
Delete everything since the beginning of time.

what is Corrupted serialized SCRAM error?

I am using mongooseim and suddenly I started getting the below error:
[warning] Corrupted serialized SCRAM: <<>> and no longer able to connect with the users. I am unable to find if somehow I enabled authentication other than PLAIN TEXT authentication.
Also, If I register a new user from the terminal command like :mongooseimctl register user10 localhost pass, it always works. But from the database all the other users look same like user10 but all those don't work.
Ohh I find it myself, uppercase characters are not allowed in the username due to which it was throwing error the above error and make sure that pass_details vale should be null.

"Login failed for user" trying to connect to SQL Server 2012

I'm trying to get acces to a remote SQL Server, using SDAC.
(in fact I have to get access to the remote DB from android application)
What I've done to set up is here
The configuration string of the TMSConnection is:
Password=mysaPwd;Data Source=RemoteIp;Initial Catalog=myDB;User ID=sa
What I get is : Login failed for user 'sa'
I tried to change the remote IP with local ip, starting the application locally on the server, but the error I get is the same.
I know that it's not a good way for safe reasons, but I want understand where the problem is
this is the authentication mode:
then, the connection configuration
Jerry Dodge was right!
I tried to connect to a different server instance than I intended
There was an old instance of SQL server already installed.
Unfortunately the error message was not clear as something like "User name or password is incorrect" but "Login failed for user", that lead me down the wrong path.
Thank you all!

Why do I get javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated only in production?

I have a grails 1.3.7 application that makes an https api call to a third party using the apache HttpClient. The third party URL I'm hitting has a valid certificate. I create and execute my request like so:
HttpClient client = new DefaultHttpClient()
List<BasicNameValuePair> queryParams = new ArrayList<BasicNameValuePair>()
queryParams.add(new BasicNameValuePair("a_parameter", "a_parameter_value"))
URI uri = URIUtils.createURI("https", "third.party.address", 443, "/some/url/for/us", URLEncodedUtils.format(queryParams, "UTF-8"), null)
HttpGet httpGet = new HttpGet(uri)
try {
log.debug "Sending request to ${uri}"
return client.execute(httpGet)
} catch(HttpException e) {
log.error "HttpException during location lookup request: ${e}"
return
} catch(IOException e) {
log.error "IOException during location lookup request: ${e}"
return
}
This works fine when I'm running my project in dev mode. I'm also able to directly call the same URL from curl and my browser with no errors. However, once my project is built into a war file and put on a tomcat instance that has a certificate/keystore defined so that clients can connect to US using https, my requests start failing with the following IOException:
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
I'm trying to figure out the point of failure here.
Why is making an https request from curl or my dev mode different than making an https request from an https configured tomcat instance?
The tomcat instance is not publicly accessible, but there are no certificate issues when I connect to it from my browser (chrome says the cert is fine, as does a verbose curl request).
I'm not an https/ssl expert by any stretch, so I'm looking for help explaining what is wrong, why it's wrong, and how I can fix it. I can provide any other needed info.
---Update---
I enabled the javax.net.debug as suggested below and the output included the following error:
java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be\
non-empty
My googling has made me think that this issue is because I'm using the following java opt when starting tomcat:
-Djavax.net.ssl.trustStore=/path/to/tomcat/conf/myStore.jks
If that's true, how can I add the things I needed in myStore.jks and not override the defaults so everyone is happy?
The solution for me ended up being that we were overriding the default java trust store with our own with the java opt. This caused the cert sent by the third party to appear to be invalid since we didn't have any of the default root certs in our myStore.jks.
By adding our self-signed cert into the default java one (/lib/security/cacerts) and removing the java opt, everything was fine.
An alternative would be to add everything in the default java store into your custom store and still use the java opt. Whichever you find more maintainable for your situation.
I have seen this error so many times. I have used the following utility to grab a cert from a site that uses SSL. Go here and grab InstallCert. Compile and Run this utility. You can use the file which was generated by this utility as a keystore.

Resources