{"id":3654,"date":"2024-09-17T10:16:07","date_gmt":"2024-09-17T09:16:07","guid":{"rendered":"https:\/\/kudzia.eu\/b\/?p=3654"},"modified":"2024-09-17T13:58:44","modified_gmt":"2024-09-17T12:58:44","slug":"using-mitmproxy-to-allow-closed-source-application-to-communicate-with-licensing-server-with-expired-tls-cert","status":"publish","type":"post","link":"https:\/\/kudzia.eu\/b\/2024\/09\/using-mitmproxy-to-allow-closed-source-application-to-communicate-with-licensing-server-with-expired-tls-cert\/","title":{"rendered":"Using mitmproxy to allow closed-source application to communicate with licensing server with expired TLS cert"},"content":{"rendered":"\n<p>we&#8217;re using a 3rd party library that shall remain nameless. vendor provides this library to us in form of few .so files, few headers and sample code. we have a small custom c++ wrapper for it.<\/p>\n\n\n\n<p>whenever library is initialized &#8211; it makes a call to licensing server and does some challenge\/response verification. on one sunny day TLS certificate on that server expired and it took over 48h for the library supplier to address it.<\/p>\n\n\n\n<p>dirty workaround to get that tool working? one would be to edit the behavior of binary&#8230; another &#8211; use the fact that the license check mechanism was working and we just had to convince library to connect to server with an expired cert; fortunately our library was well behaved and obeyed <em>http_proxy<\/em>, <em>https_proxy <\/em>environmental variables:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get install mitmproxy\n\n# run mitmproxy temporarily - it can be under unprivileged user\n# during the first run it'll create in ~\/.mitmproxy it's own certificate \n# that will be used to sign decrypted and re-encrypted communication\n\nmkdir \/usr\/local\/share\/ca-certificates\/mitmproxy\nopenssl x509 -inform PEM -in \/home\/mitmproxyuser\/.mitmproxy\/mitmproxy-ca-cert.cer -out \/usr\/local\/share\/ca-certificates\/mitmproxy\/mitmproxy-ca-cert.crt\nupdate-ca-certificates\n\n# start mitmproxy again, under mitmproxyuser\nmitmproxy --ssl-insecure --mode upstream:http:\/\/10.1.2.3:3128\n\n# start our wrapper for 3rd party lib, instruct it to use mitmproxy\n\nhttp_proxy=127.0.0.1:8080 https_proxy=127.0.0.1:8080 .\/ourtool <\/code><\/pre>\n\n\n\n<p>this, obviously, is insecure &#8211; mitmproxy would blindly trust not only expired certs but also potentially incorrect certs inserted by attacker. for us that was acceptable risk.<\/p>\n\n\n\n<p>we&#8217;re in a very sad world where DRM for all sort of things that we think we&#8217;ve bought can stop working at any time&#8230; or for code that we think we run on our own infrastructure can stop working because its supplier goes belly up or has an outage.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>we&#8217;re using a 3rd party library that shall remain nameless. vendor provides this library to us in form of few .so files, few headers and sample code. we have a small custom c++ wrapper for it. whenever library is initialized &#8211; it makes a call to licensing server and does some challenge\/response verification. on one [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[],"class_list":["post-3654","post","type-post","status-publish","format-standard","hentry","category-unimportant"],"_links":{"self":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3654","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/comments?post=3654"}],"version-history":[{"count":2,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3654\/revisions"}],"predecessor-version":[{"id":3657,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3654\/revisions\/3657"}],"wp:attachment":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/media?parent=3654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/categories?post=3654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/tags?post=3654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}