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

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.

Related

Graphql server - Can't access via IP address url (localhost works fine)

I would like to link my Expo(React Native) app to local GraphQL backend,
http://localhost:4000/ <- Works fine
http://192.168.X.X:4000/ <- This doesn't work
I do see the Apollo Studio page, but it comes up with the below message:
Unable to reach server
Network requests from Studio on HTTPS to your HTTP endpoint are not secure,
so we cannot introspect your endpoint.
https://studio.apollographql.com/sandbox/explorer
Apollo Studio has a special exception that allows it to communicate with "localhost" over http, but all other endpoints must be over https.
If you (like me) are running virtual machines on your local machine and need to use Apollo Studio, the only solutions are to make the connection https somehow, or forward a port in your host OS so that you can access it via localhost. How to do THAT depends on your OS.

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

nodejs/curl http request is slow compared to postman rest client

I call a Rest API from node.js and Postman-Rest Client (chrome app).
Always using the same computer, same endpoint and same parameters.
In node.js I get ~400ms for http and ~700ms for https.
In Postman I get ~250ms for http and https.
Libraries I used in node.js: http, https, request, kinvey (node client of the api). All of them got the the same result more or less.
Why my node is slower?
node.js 0.10.36
Edit:
it's not about node, i get the same result with curl.
when running in browser using XMLHttpRequest i get better times.
from analysing the logs I found that TCP connect and SSL handshake takes about 500ms. It may be that TCP connect and SSL handshake works differently in browser.
Here you can find some help.
I am also facing issues with nodejs application server on linux instance. But dont blame nodejs as real issue is in linux systems.
Issue : any outbound request from machine need to find the domain , hence it always lookup the DNS entries & always handshakes with secure/unsecure protocols. This is actually the time taking scenario.
You can verify by doing CURL request.
curl --trace-time -v https://outboundserver.com
Solution : We have to White List IP of outbound server in our own DNS entries. take a look below ...
IN Windows : automatically does the mapping of servers in own dns entries.
IN Linux : We have to manually add the hosts corresponding to IP Address.
Manually add an entry in /etc/hosts file below any configuration like localhost.
127.0.0.1 localhost
outbound.servers.ip.address www.outboundserver.com
Finally check with the curl request again, it should give faster response.
curl --trace-time -v https://outboundserver.com

strophe js not working after installing ssl certificate

I am developing a real time application for that i had installed openfire and using strophe js to integrate it on client side and everything works fine
but later on we had to integrate ssl certificate to website and after adding ssl certificate strophe stops working and giving error
i had added self attested certificates in openfire too but still no use
This looks like an issue with your web server config and not strophe. Speculating based on the little info I have about your configuration I would guess that openfire bosh config is listening on a port other than the default ssl 443 port.
You will either need to specify the port number openfire is listening on (adventurefriend.com:8443 or something) or use an http rewrite in your Apache config to rewrite requests with ^/http-bind to that port.

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.

Categories