User Tools

Site Tools


fetching_20a_20secure_20web_20page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
fetching_20a_20secure_20web_20page [2024/01/05 00:22] – external edit 127.0.0.1fetching_20a_20secure_20web_20page [2025/03/23 15:13] (current) richardrussell
Line 1: Line 1:
 =====Fetching a secure web page===== =====Fetching a secure web page=====
  
-//by Richard Russell, July 2009, updated July 2018//\\ \\  The procedure listed below fetches the contents of a secure (**https:**) web page to a specified file; it uses the [[http://www.openssl.org/|OpenSSL]] library and requires the files **libssl-1_1.dll** and **libcrypto-1_1.dll** to be available. They can be obtained from  [[https://slproweb.com/products/Win32OpenSSL.html|this page]]; download and install **Win32OpenSSL_Light-1_1_0h.exe** from there.  You should normally choose the option of installing the DLLs in the Windows system directory.+//by Richard Russell, July 2009, updated July 2018 and March 2025//
  
-If you want to distribute **libssl-1_1.dll** and **libcrypto-1_1.dll** with your application then store them in **@dir$** and embed them in the executable. Alternatively you can put them in **@lib$** (or a sub-directory) but in that case you will need to amend the procedure below to load them explicitly from that location.+The procedure listed below fetches the contents of a web resource to a specified file; it uses the code listed in the //BBC BASIC for Windows// [[https://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#urlmon|manual]] (it also runs in //BBC BASIC for SDL 2.0// but in **Windows** only): 
 + 
 +<code bb4w> 
 +      url$ = "https://www.fortify.net/sslcheck.html" 
 +      file$ = @tmp$ + "sslcheck.html" 
 +      SYS "LoadLibraryA", "URLMON.DLL" TO urlmon% 
 +      SYS "GetProcAddress", urlmon%, "URLDownloadToFileA" TO `URLDownloadToFile` 
 +      SYS `URLDownloadToFile`, FALSE, url$, file$, 0, FALSE TO fail% 
 +      IF fail% ERROR 100, "File download failed" 
 +      OSCLI "RUN notepad """ + file$ + """" 
 +</code> 
 + 
 +If you find this code doesn't work, you can instead try the routine below which uses the  
 + [[http://www.openssl.org/|OpenSSL]] library and requires the files **libssl-3.dll** and **libcrypto-3.dll** to be available. They can be obtained from  [[https://slproweb.com/products/Win32OpenSSL.html|this page]]; download and install **Win32OpenSSL_Light-3_4_1.exe** from there.  You should normally choose the option of installing the DLLs in the Windows system directory. 
 + 
 +If you want to distribute **libssl-3.dll** and **libcrypto-3.dll** with your application then store them in **@dir$** and embed them in the executable. Alternatively you can put them in **@lib$** (or a sub-directory) but in that case you will need to amend the procedure below to load them explicitly from that location.
  
 The procedure should be called in the following context: The procedure should be called in the following context:
Line 31: Line 46:
       PROC_initsockets       PROC_initsockets
  
-      SYS "LoadLibrary", "libcrypto-1_1.dll" TO libeay% +      SYS "LoadLibrary", "libcrypto-3.dll" TO libeay% 
-      IF libeay% = 0 PROCsslcleanup : ERROR 100, "Cannot load libcrypto-1_1.dll"+      IF libeay% = 0 PROCsslcleanup : ERROR 100, "Cannot load libcrypto-3.dll"
       SYS "GetProcAddress", libeay%, "BIO_new_socket"   TO `BIO_new_socket`       SYS "GetProcAddress", libeay%, "BIO_new_socket"   TO `BIO_new_socket`
  
-      SYS "LoadLibrary", "libssl-1_1.dll" TO libssl% +      SYS "LoadLibrary", "libssl-3.dll" TO libssl% 
-      IF libssl% = 0 PROCsslcleanup : ERROR 100, "Cannot load libssl-1_1.dll"+      IF libssl% = 0 PROCsslcleanup : ERROR 100, "Cannot load libssl-3.dll"
       SYS "GetProcAddress", libssl%, "TLSv1_2_method"   TO `TLSv1_2_method`       SYS "GetProcAddress", libssl%, "TLSv1_2_method"   TO `TLSv1_2_method`
       SYS "GetProcAddress", libssl%, "SSL_CTX_new"      TO `SSL_CTX_new`       SYS "GetProcAddress", libssl%, "SSL_CTX_new"      TO `SSL_CTX_new`
fetching_20a_20secure_20web_20page.1704414128.txt.gz · Last modified: 2024/01/05 00:22 by 127.0.0.1