mTLS in a NestJS application
trsp400
TRIALOP

2 years ago

Hello, I have a Nestjs backend deployed in Railway, this backend provides a certificate generation to my clients, which they will use on their side to communicate with my backend securely. I need to use the following options in my nest configuration:

requestCert: true,
rejectUnauthorized: true,

I want to know if it's possible to implement this type of backend in Railway, from my tests here seems it's not. But I'd like to hear from the team and the community. And if there's a workaround, let me know as well, I'd like to keep using Railway for my backend.

9 Replies

brody
EMPLOYEE

2 years ago

As Railway handles HTTPS itself it wouldn't be something you could do as well with their HTTPS proxy, you could possible expose your app with the TCP proxy instead?


trsp400
TRIALOP

2 years ago

Do you mean to handle the HTTPS through my nest application? Like using directly the port 443 in my nest configuration?


brody
EMPLOYEE

2 years ago

Please share your use case, why wouldn't the SSL certs automatically generated for you by Railway (let's encrypt) be sufficient for secure communication?


trsp400
TRIALOP

2 years ago

I'm building a payment gateway platform, which communicates with banks (I'm from Brazil), these banks also require me to manually login into their platform and create a new "application", generate the certificates and clientId and clientSecret. As I'm building this gateway, I also need to have this secure communication with my clients, they will need to generate a certificate on my platform (I already generate this certificate with node-forge), and they will need to implement these certificates in their httpsAgent to keep the information encrypted. The problem is that whenever I use:

requestCert: true,
rejectUnauthorized: true,

The application stops receiving the requests, like it's not possible to be reached, even though I send the certificate on my end. I also would need to use my own SSL certificate for that due to the certificate generation that I have on my side.


brody
EMPLOYEE

2 years ago

If you need to manage the certs yourself you would need to use the TCP proxy instead of the HTTP proxy.


trsp400
TRIALOP

2 years ago

Could you elaborate a bit more on that, please? Maybe i'm getting it wrong...


brody
EMPLOYEE

2 years ago

You aren't seeing the option for the TCP proxy because you currently have an HTTP proxy enabled, you need to remove it before you can add a TCP proxy.


trsp400
TRIALOP

2 years ago

Hmm, how do I do that?


brody
EMPLOYEE

2 years ago

Click the trash bin icon.


Loading...