Https connection fails through POSTMAN - node.js

I'm running nodejs app using node13.1.
When access hit the end point using POSTMAN, I get the following error:
"Error: Client network socket disconnected before secure TLS connection was established"
POSTMAN Console Error Screenshot
Can anyone help?

Related

Azure Devops Service Hooks (Webhook) fails with The underlying connection was closed: An unexpected error occurred on a send

I've configured a service hook -> webhook that invokes a remote HTTPS URL with a valid certificate.
When testing the webhook I get this error:
There was an error sending the request, so there was no response.
Error(s):
An error occurred while sending the request.
The underlying connection was closed: An unexpected error occurred on a send.
You may not call this function on a different context than the original request
Invoking the same URL with curl everything is fine.
EDIT: Reading answers with a similar error I thought the problem could be related to the TLS version used by Azure Devops.
My remote service was enabled for TLS 1.3 and 1.2 and failed with <= 1.1.
I configured it to allow TLS 1.0 and 1.1 as well and I keep getting the same error.
I had checked "Accept untrusted SSL certificates". Unchecking it fixed the problem.

Getting 502 Bad Gateway: Registered endpoint failed to handle the request error on pcf

I have deployed the nodejs application to a pivotal cloud foundry. Deployment is successful, but when I am trying to access any page which has a post request, getting the '502 Bad Gateway: Registered endpoint failed to handle the request' error. For handling port, I have used the cfenv module, but I am getting this error for post requests in which I have post URL with the port as 'https://my-neptune-cluster.cluster-cr2fhfjprba.us-east-1.neptune.amazonaws.com:25881'. Can someone help me with how can we resolve that?

Why am I getting connection error on calling notify on Azure SignalR

I have configured a SignalR resource on my Azure account and am sending a message to the SignalR Hub using the below snippet in an Azure Function written in C#:
await signalRMessages.AddAsync(new SignalRMessage()
{
Target = "notify",
Arguments = new object[] { requestBody }
});
However, I keep getting the below error.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I have also verified that the Azure function URL for negotiate function returns me the below information as expected.
{"endpoint":"https://xxxxxxx.service.signalr.net:5001/client/?hub=broadcast","accessKey":"yyyyyyy"}
Why am I getting the connection error and what could I change in my configuration?
This error means no server listening at specified ip/port that you are trying to connect to. It can be caused by using the wrong IP address or the wrong PORT.

Spring OAuth2 Client: I/O error on POST request for oauth2/v2.0/token

Im using spring oauth2 client against Azure AD - I have it working successfully on my localhost:8080
When I deploy this working OAuth2 Client code against Azure AD on remote server with https enabled https://serverhost.corp.com , I get an Auth Code during url redirection, but the access_token request throws
org.springframework.security.oauth2.core.OAuth2AuthenticationException: [invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: I/O error on POST request for "https://login.microsoftonline.com/<tenantId>/oauth2/v2.0/token": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
The only difference in localhost:8080 and https://serverhost.corp.com is the port from 8080 to 443 and SSL Certificate
I set the proxy to be sure, but this isnt a proxy issue.
I also see the url redirection happens and I get the Auth Code
Redirecting to 'https://login.microsoftonline.com/<Tenant>/oauth2/v2.0/authorize?response_type=code&client_id=<ClientId>&scope=openid%20profile%20User.Read&state=<state>&redirect_uri=https://serverhost.corp.com/login/oauth2/code/azure'
I get the Auth Code too
/login/oauth2/code/azure?code=<CODE_HERE>
http
.csrf().disable()
.authorizeRequests()
.anyRequest().authenticated()
.and()
.oauth2Login()
app.properties are
server.port: 443
server.ssl.key-store: myapp-prod.jks
server.ssl.key-store-password: MyPassword
server.ssl.keyStoreType: JKS
server.ssl.keyAlias: server
org.springframework.security.oauth2.core.OAuth2AuthenticationException: [invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: I/O error on POST request for "https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
at org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationProvider.authenticate(OAuth2LoginAuthenticationProvider.java:110) ~[spring-security-oauth2-client-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
Sorry, I had the proxy settings wrong,
In tomcat, I added setenv.bat with the below and it worked
set JAVA_HOME="E:\jdk-9.0.4"
set JAVA_OPTS=-Dhttps.proxySet=true -Dhttps.proxyHost=serverhost -Dhttps.proxyPort=8080 -Dhttp.proxyHost=serverhost -Dhttp.proxyPort=8080

Checking in nodeJS Express if IIS Client Cert Authentication went ok

I have some client machines that connect to my IIS server using client certificate authorization. I have a node.js webapp published on IIS (using iisnode) that receives the requests from the clients.
Is there a way in express to know if the authentication was ok? I know that if the authentication was not ok the http request does not reach to express because it is rejected but I need a field to check if it was ok, because I access the same webapp without ssl and I this particar request only needs to be called if the call was using the client ssl authentication.
I tried with req.socket.authorized but it is undefined and with req.socket.getPeerCertificate(true) I am getting TypeError: req.socket.getPeerCertificate is not a function
req.secure
A Boolean property that is true if a TLS connection is
established. Equivalent to:
'https' == req.protocol;
http://expressjs.com/en/api.html#req.secure

Resources