How to fix Error: SSL connect error when connecting to aws ec2 instance - javascript

I just created an EC2 instance for my web server and I run into this whenever i try connecting to it:
This site can’t provide a secure connection
18.170.25.198 sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

Just connect on http, it works for me
http://18.170.25.198:8001/api

Related

Calling HTTP Node server inside HTTPS instance, SSL error

I'm trying to connect to a socket.io inside a Node server from a React client.
Both, the React client and the instance that the Node server is located (it's a microservice, there's also a Java container running there, both within a separated docker container) have https protocols. React client is inside a s3 bucket.
The thing is, Node server is HTTP only, has no certificate, and it's causing the request to the socket.io to fail.
The connection happens without any trouble inside de develop EC2, which is not HTTPS, also running normally with localhost.
Cors are enabled.
Is there a way, without having to turn Node serve into HTTPS, to make this requests not return SSL erros?
If not, what is the easiest way to turn it into a HTTPS server to run along with the Java server?
Thanks a lot!
A very short answer. Try using nginx as WebSocket proxy for you socket.io server.
Here are couple links:
nginx as WebSocket proxy
SSL configuration to make it an https
Socket.io official configuration

Web socket connection does not work over SSL

I have Web Socket that works perfectly fine on localhost and production (https://www.example.com) environment.
However, when I deploy the same code to pp environment (https://pp.example.com) I get WebSocket handshake: Unexpected response code: 404
I have AWS certificate manager generated certificate for domain example.com, with additional domain name www.example.com and pp.example.com
www.example.com and pp.example.com are sitting on different server so they have different ip addresses.
When I go to www.example.com and make the following call,
let ws = new WebSocket("wss://www.example.com/ws");
It works perfectly fine.web socket is connected.
However, when I switch to pp.example.com and make the following call
let ws = new WebSocket("wss://pp.example.com/ws");
I get error from Safari, Firefox and Chrome:
WebSocket connection to 'wss://pp.example.com/ws' failed: Error during
WebSocket handshake: Unexpected response code: 404
Any ideas?
The code are exactly the same.
They are deployed on aws beanstalk.
production environment is using global accelerator + application load balancer + EC2
pp environment is using classic load balancer + EC2
The problems lies in load balancer's listener.
I was using HTTPS for traffic forwarding, while web socket works on TCP level, therefore, it should be SSL TCP instead.
See the attached screenshot at the following for load balancer

Failed to connect to SQLEXPRESS - Node.js

I am trying to connect to my MS SQL database via node.js (Express), but the connection cannot be established. I have probably wrong configuration, but I have tried everything and nothing worked. I also enabled TCP/IP in configuration Manager.
Here is my JS code: https://snipboard.io/ufk49d.jpg
Here is one of my errors: https://snipboard.io/wyTbLi.jpg
When I add localhost or IP adress before SQLEXPRESS in server configuration, it thow this error: https://snipboard.io/RE6Xov.jpg
And also, I added new user and allow SQL auth and windows auth connection.
Thanks for your tips!
Can you put your machine name in server parameter?
server: 'YOUR_MACHINE_NAME\\SQLEXPRESS',

How can I establish a secure connection to a websocket on localhost?

We have an application which we run on a POS terminal, that should receive data from an application running on the same machine, while displaying content from a remote site which is loaded over HTTPS.
To receive the data from the local application, we want to use websockets, which is working fine so far. However, when the site we're displaying is loaded over HTTPS, the websocket connection is required to be encrypted as well.
Because we can't really get a proper certificate for localhost, we're just using a self-signed one. But Chrome won't connect to a websocket that uses a self-signed certificate.
How can we resolve this problem? We can't use an unencrypted websocket, we can't use a self-signed certificate for the encrypted one and we can't get a signed certificate for localhost. What option am I missing?
If you have admin privileges on the POS terminals, how about adding a line to the HOSTS file like:
127.0.0.1 localhost.mycompany.com
Now you can use a real certificate for localhost.mycompany.com in the server application.

Node.js on Azure Worker Role w/ SSL results in ERR_SSL_PROTOCOL_ERROR

I have a WorkerRole configured to start node.exe via the Runtime/EntryPoint/ProgramEntryPoint element in the csdef and have a HttpsIn EndPoint configured for https on port 443 w/ a valid certificate. I'm also setting the PORT environment variable in Runtime/Environment which is used by node to listen on for incoming requests.
When I start the service (either in local dev fabric or in Azure) and try to hit the service I get the following error:
SSL connection error
Unable to make a secure connection to the server. This may be a problem with the server, or it may be requiring a client authentication certificate that you don't have.
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.
I have verified that node.exe is indeed started when the service starts, and if I look up the local port in the Compute Emulator, usually something like:
http://localhost:444
I am able to successfully hit node directly with that using my browser. I am also able to hit node through Azure when SSL is not configured.
What am I missing? Thanks!
The issue was that I was using the http module instead of the https module when starting the web server in Node. Works once I started the https server using the ssl certificate.
I was following a guide for SSL w/ Node in a WebRole, which requires a different set up than SSL w/ Node in WorkerRole.

Categories