openssl - https - mac lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- upsidasi · 2018-11-20 11:33 Hi, I'm testing HTTPS with fpc (http://wiki.freepascal.org/fphttpclient) on Mac: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   url := 'https://jsonplaceholder.typicode.com/posts/42';   urlrequest := TFPHTTPClient.Create(nil);  res := urlrequest.Get(url);  urlrequest.Free;  but I can't connect to the server (see error.jpg) The server is reachable from the Mac (I can access it with Safari) and I tested the same code on Linux and Windows. Here some extra info about my Mac and openssl: $ uname -a   Darwin Jacks-iMac.local 16.0.0 Darwin Kernel Version 16.0.0: Mon Aug 29 17:56:20 PDT 2016; root:xnu-3789.1.32~3/RELEASE_X86_64 x86_64 $ openssl version   OpenSSL 0.9.8zh 14 Jan 2016 $ ll /usr/lib/libssl*   -rwxr-xr-x  1 root  wheel   386K Sep 14  2016 libssl.0.9.7.dylib*   -rwxr-xr-x  1 root  wheel   631K Sep 14  2016 libssl.0.9.8.dylib*   -rw-r--r--  1 root  wheel   921K Sep 14  2016 libssl.35.dylib   lrwxr-xr-x  1 root  wheel    18B Sep 21  2016 libssl.dylib@ -> libssl.0.9.8.dylib $ ll /usr/lib/libcrypto*   -rwxr-xr-x  1 root  wheel   1.9M Sep 14  2016 libcrypto.0.9.7.dylib*   -rwxr-xr-x  1 root  wheel   2.6M Sep 14  2016 libcrypto.0.9.8.dylib*   -rw-r--r--  1 root  wheel   4.0M Sep 14  2016 libcrypto.35.dylib   lrwxr-xr-x  1 root  wheel    21B Sep 21  2016 libcrypto.dylib@ -> libcrypto.0.9.8.dylib Any help? Thanks! ---------------------------------------------------------------------- CCRDude · 2018-11-20 12:17 Are you using sandboxing? If so, OpenSSL will not work. I've changed my code to use NSURLRequest when compiled for Mac and it seems to work just fine. ---------------------------------------------------------------------- upsidasi · 2018-11-20 12:29 I'm not using sandboxing or at least I don't think I am. Sandboxing requires some configuration and specific operations around your application, right? (https://macpgmr.github.io/ObjP/SandboxingAppsOnMac.html) If that's so I'm not doing any. I'll give NSURLRequest a look, thanks ---------------------------------------------------------------------- Thaddy · 2018-11-20 13:02 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$mode objfpc}{$H+}uses fphttpclient, fpopenssl, openssl;Var   URLRequest : TFPHttpClient;  URL,Res:string;begin  url := 'https://jsonplaceholder.typicode.com/posts/42';   urlrequest := TFPHTTPClient.Create(nil);  try    res := urlrequest.Get(url);    writeln(res);  finally    urlrequest.Free;  end;end. Now..... this happens to work too...But not with sandboxing on Macs (yet). ---------------------------------------------------------------------- upsidasi · 2018-11-20 15:25 Can you suggest me what should I do to turn off this "sandboxing"? ---------------------------------------------------------------------- CCRDude · 2018-11-20 15:34 Sandboxing is only enabled if you codesign an executable while providing an entitlements file. Or, alternatively, configure a sandbox for the app at system level. ---------------------------------------------------------------------- upsidasi · 2018-11-20 16:14 thanks! therefore sandboxing is not the issue here. ---------------------------------------------------------------------- upsidasi · 2018-11-23 16:50 I tried the same code on a MacOS High Sierra 10.13.6 which has a slightly different libssl/libcrypto situation: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   $ ls -l /usr/lib/libssl*     -rwxr-xr-x  1 root  wheel  392912 Dec  1  2017 /usr/lib/libssl.0.9.7.dylib    -rwxr-xr-x  1 root  wheel  630144 Dec  1  2017 /usr/lib/libssl.0.9.8.dylib    -rw-r--r--  1 root  wheel  947104 Mar 28  2018 /usr/lib/libssl.35.dylib    -rw-r--r--  1 root  wheel  890800 Mar 28  2018 /usr/lib/libssl.43.dylib    lrwxr-xr-x  1 root  wheel      15 Dec 31  2017 /usr/lib/libssl.dylib -> libssl.35.dylib   $ ls -l /usr/lib/libcrypto*       -rwxr-xr-x  1 root  wheel  2023616 Mar 28  2018 /usr/lib/libcrypto.0.9.7.dylib    -rwxr- xr-x  1 root  wheel  2599488 Dec  1  2017 /usr/lib/libcrypto.0.9.8.dylib    -rw-r--r--  1 root  wheel  4232208 Mar 28  2018 /usr/lib/libcrypto.35.dylib    -rw-r--r--  1 root  wheel  4274832 Mar 28  2018 /usr/lib/libcrypto.41.dylib    lrwxr-xr-x  1 root  wheel       18 Dec 31  2017 /usr/lib/libcrypto.dylib -> libcrypto.35.dylib  and it works fine there. Anyhow I switched to NSURLRequest to make my program work on both Macs. Thank you CCRDude for the suggestion!