{"id":10936,"date":"2025-06-16T06:00:48","date_gmt":"2025-06-16T06:00:48","guid":{"rendered":"https:\/\/cheapwindowsvps.com\/blog\/secure-your-client-server-application-traffic-on-windows-with-stunnel-a-comprehensive-guide\/"},"modified":"2025-07-15T12:02:24","modified_gmt":"2025-07-15T12:02:24","slug":"secure-your-client-server-application-traffic-on-windows-with-stunnel-a-comprehensive-guide","status":"publish","type":"post","link":"https:\/\/cheapwindowsvps.com\/blog\/secure-your-client-server-application-traffic-on-windows-with-stunnel-a-comprehensive-guide\/","title":{"rendered":"Secure Your Client-Server Application Traffic on Windows with Stunnel: A Comprehensive Guide"},"content":{"rendered":"<p>The <a href=\"https:\/\/cheapwindowsvps.com\/\"><strong>Stunnel tool<\/strong><\/a> acts as a proxy service that enables the creation of a secure TLS tunnel for client-server applications lacking inherent encryption capabilities. It is often more efficient to use Stunnel for securing access to a specific application rather than deploying a comprehensive VPN solution.<\/p>\n<p>Stunnel can function in either server or client mode. In client mode, it captures traffic from the client application, encrypts it, and forwards it to the server, where decryption occurs before sending to the intended application. Importantly, this setup doesn\u2019t require any modifications to either the client or server application. Additionally, Stunnel supports client authentication through certificates and is available for both Windows and Linux platforms.<\/p>\n<h3>Configuring Stunnel Server on Windows<\/h3>\n<p>To set up Stunnel on a <strong><a href=\"https:\/\/cheapwindowsvps.com\/\">Windows server<\/a><\/strong>, start by downloading the installer from <a href=\"https:\/\/www.stunnel.org\/downloads.html\" target=\"_blank\" rel=\"nofollow noopener\">Stunnel&#8217;s official website<\/a> and complete the installation using the default settings, which include <code>openssl<\/code>.<\/p>\n<p>Next, generate the keys and certificates for the Certificate Authority (CA), server, and clients. Open a command prompt and navigate to the install directory:<\/p>\n<pre><code class=\"language-bash\">cd \"C:Program Files (x86)stunnelbin\"<\/code><\/pre>\n<p>Follow these steps to create the necessary keys and certificates:<\/p>\n<ol>\n<li>Generate the CA key:\n<pre><code class=\"language-bash\">openssl genpkey -algorithm RSA -out ca.key<\/code><\/pre>\n<\/li>\n<li>Create the CA certificate:\n<pre><code class=\"language-bash\">openssl req -new -x509 -key ca.key -out ca.crt -subj \"\/O=woshubLTD\/OU=IT\/CN=CA_webserver1.com\"<\/code><\/pre>\n<\/li>\n<li>Create a private key for the server:\n<pre><code class=\"language-bash\">openssl genpkey -algorithm RSA -out server.key<\/code><\/pre>\n<\/li>\n<li>Generate a CSR for the server certificate:\n<pre><code class=\"language-bash\">openssl req -key server.key -new -out server.csr<\/code><\/pre>\n<\/li>\n<li>Sign the server certificate with the root CA:\n<pre><code class=\"language-bash\">openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365 -subj \"\/O=woshubLTD\/OU=IT\/CN=server_webserver1.com\"<\/code><\/pre>\n<\/li>\n<li>Generate the client&#8217;s private key:\n<pre><code class=\"language-bash\">openssl genpkey -algorithm RSA -out client.key<\/code><\/pre>\n<\/li>\n<li>Create a CSR for the client certificate:\n<pre><code class=\"language-bash\">openssl req -key client.key -new -out client.csr<\/code><\/pre>\n<\/li>\n<li>Sign the client certificate:\n<pre><code class=\"language-bash\">openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client.crt -days 365 -subj \"\/O=woshubLTD\/OU=IT\/CN=client1_webserver1.com\"<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>Now, move the <code>ca.crt<\/code>, <code>server.crt<\/code>, and <code>server.key<\/code> files to the <code>C:Program Files (x86)stunnelconfig<\/code> directory.<\/p>\n<p>Edit the <code>stunnel.conf<\/code> file, and include the following configuration settings:<\/p>\n<pre><code class=\"language-ini\">; Write logs to stunnel.logdebug = infooutput = stunnel.logoptions = CIPHER_SERVER_PREFERENCEoptions = NO_SSLv2options = NO_SSLv3options = NO_TLSv1sslVersion = TLSv1.2sslVersion = TLSv1.3ciphers = ECDHE-RSA-AES256-GCM-SHA384cert = server.crtkey = server.keyCAfile = ca.crt[ITPoral]accept = 192.168.158.144:443connect = 127.0.0.1:80verify=2<\/code><\/pre>\n<p>Ensure the selected port in the <strong>accept<\/strong> line is free. Configure Windows Defender Firewall to allow incoming connections on this port:<\/p>\n<pre><code class=\"language-powershell\">New-NetFirewallRule -DisplayName \"ITPoral_stunnel_443\" -Direction Inbound -LocalPort 443 -Protocol TCP -Action Allow<\/code><\/pre>\n<p>After that, run <code>Stunnel.exe<\/code>, monitor the GUI logs for any configuration errors, and debug as necessary.<\/p>\n<p>To run Stunnel service, execute:<\/p>\n<pre><code class=\"language-bash\">\"C:Program Files (x86)stunnelbinstunnel.exe\" -install \"C:Program Files (x86)stunnelconfigstunnel.conf\"Start-Service wrapper<\/code><\/pre>\n<h3>Stunnel Client Configuration Example on Windows<\/h3>\n<p>On the client-side, install Stunnel from the same distribution and transfer the <code>ca.crt<\/code>, <code>client.crt<\/code>, and <code>client.key<\/code> files to the <code>C:Program Files (x86)stunnelconfig<\/code> folder. Then, set up the configuration in <code>stunnel.conf<\/code> as follows:<\/p>\n<pre><code class=\"language-ini\">[ITPoral]client = yesaccept = localhost:8080connect = 192.168.158.144:443CAfile = ca.crtcert = client.crtkey = client.keyverify=2<\/code><\/pre>\n<p>After saving the configuration file, run Stunnel manually to check for errors. Access the service via <code>localhost:8080<\/code> on your browser, and Stunnel will securely redirect the connection.<\/p>\n<p>To improve convenience, you can merge the client certificates and keys into a single file and update the configuration accordingly.<\/p>\n<h3>Certificate Management<\/h3>\n<p>For revoking compromised certificates, utilize the <code>CRLpath<\/code> option in the server configuration to indicate where the revoked certificates are stored. Similarly, use the <code>CApath<\/code> option to specify the directory containing the allowed certificates.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Stunnel tool acts as a proxy service that enables the creation of a secure TLS tunnel for client-server applications lacking inherent encryption capabilities. It is often more efficient to use Stunnel for securing access to a specific application rather than deploying a comprehensive VPN solution. Stunnel can function in either server or client mode. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":10937,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[99,121],"tags":[],"class_list":["post-10936","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-11","category-windows-server-2025"],"_links":{"self":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/10936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/comments?post=10936"}],"version-history":[{"count":2,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/10936\/revisions"}],"predecessor-version":[{"id":10978,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/10936\/revisions\/10978"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media\/10937"}],"wp:attachment":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media?parent=10936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/categories?post=10936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/tags?post=10936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}