By rpdramybadr
I’ve been reading in the Node.JS docs about SSL attributes for the Node.JS connector to MariaDB server:
https://mariadb.com/kb/en/nodejs-connection-options/#two-way-ssl-authentication
I’m left with these questions for my current setup is a 3-tier architecture (Client–Nodejs Webserver–MariaDB):
Is it fine to ask users to upload their corresponding files (client-key, client-cert, CA-cert set by the database admin) to the webserver through a login form in which they can submit their credentials too?
Thanks a lot for any guidance!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Heya,
TLS mutual authentication is a great way to increase the security of your application by requiring both client and server to authenticate each other. However, there are potential security and user experience concerns with asking users to upload their own client certificates and keys. Here’s why:
User Experience: Managing client-side certificates is a complex task for most users, and it’s not something that the average user is accustomed to. It adds friction to the login process and could result in lost or confused users.
Security: If a user’s private key is compromised during transfer (or if they accidentally upload it somewhere insecure), that user’s database account would be at risk. You should never handle a user’s private key, and users should never be encouraged to send their private keys over the network, even over a secure connection.
A more typical setup might be like this:
Web Server <-> Database Server: Use mutual TLS authentication. Your web server would have a client key and certificate, and your database server would require clients to authenticate using this certificate. This ensures that only your web server can connect to the database server.
Client <-> Web Server: Use standard username/password authentication over HTTPS, and manage user sessions using secure cookies or tokens. When a user logs in, the web server would establish a connection to the database server on their behalf. The web server would then perform operations for the logged-in user.
This setup provides strong security while offering a typical user experience. The web server mediates all access to the database server, which reduces the attack surface area. You can also add other security measures like rate-limiting, automated suspicious activity detection, etc.
If you absolutely need to use client certificates for user authentication, consider distributing certificates to users out of band (i.e., not through the application itself) and instructing users to configure their web browsers to use the certificate when connecting to your site. This is a complex setup and could be overkill for most applications, and again, it is not user-friendly for most people. The use of client-side certificates for users is more common in corporate or high-security environments where additional controls and training can be provided.
Remember, the right authentication setup depends on your specific use case and security requirements. Always consider both the user experience and security implications of your choices.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.