Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual C, C89 and Win32 Shining Light precompiled fixes #188

Closed
wants to merge 3 commits into from

Conversation

bulk88
Copy link
Contributor

@bulk88 bulk88 commented Aug 4, 2020

Only test fail I get with Perl 5.25 (yes dev) and VC 2013 is

t/local/38_priv-key.t .................. ok
t/local/39_pkcs12.t .................... OPENSSL_Uplink(526F6340,08): no OPENSSL
_Applink
t/local/39_pkcs12.t .................... Dubious, test returned 1 (wstat 256, 0x
100)
Failed 19/19 subtests
t/local/40_npn_support.t ............... skipped: fork() not supported on MSWin3
2
t/local/41_alpn_support.t .............. skipped: fork() not supported on MSWin3

but OpenSSL's applink is a whole nother complicated story for another PR and I already had a try at
applink in 2015 and it was never merged and I never got around to reviewing my patch on CPAN RT
about applink (a C std lib swap/vtable/abstraction layer OpenSSL invented for Win32 to deal with the
multiple CRTs DLLs in 1 process problem). After this PR a user only needs to install Shining Light 50 MB full size dev MSI and just "click next until it says finish" then no interaction "cpan install Net::SSLeay" and it just works. No env vars, no editing config files. simcop2387 on IRC gets 1% credit for the loop fix.

bulk88 added 3 commits August 3, 2020 13:42
…les"

-no need to set OPENSSL_PREFIX in majority of cases now with Shining Light
-dates to day 1 commit cb98af3

Fixed some compiler warnings. Courtesy kmx.

Fixed a problem with Win32 detection. Courtesy kmx.

git-svn-id: r334

Committer: Mike McCauley <[email protected]>  2012-04-02 04:38:39
-----------------
this caused
-----------------
C:\sources\p5-net-ssleay>perl Makefile.PL
Do you want to run external tests?
These tests *will* *fail* if you do not have network connectivity. [n] y
*** Found OpenSSL-1.1.1g installed in C:\Program Files\OpenSSL-Win32
*** Be sure to use the same compiler and options to compile your OpenSSL, perl,
    and Net::SSLeay. Mixing and matching compilers is not supported.
Warning (mostly harmless): No library found for -llibeay32
Warning (mostly harmless): No library found for -lssleay32
Generating a gmake-style Makefile
Writing Makefile for Net::SSLeay
-------------------
With Shining Light precompiled OpenSSL and eventual there is a link failure
since the lib file paths dont exist that are given to EUMM and EUMM
eventually puts in MKF then fed to link.exe cmd line, since the $dir loop
kept spinning and push new paths into %opts even though in an earlier
iteration the .lib file was found on disk

-fix a CC warning too about redefinition, perl core provides this flag
 automatic nowadays if the VC version is new enough to need this
@h-vn
Copy link
Contributor

h-vn commented Aug 20, 2020

I have a Windows machine I'm going to try this pull request. Before proceeding, which Perl distribution is recommended. Is it ActovePerl, Strawberry or something else? RT 101638 mentions ActivePerl but I thought I'd check where this needed.

The RT ticket also has an update by jkahrman from February 2020 that shows updates that were needed to get it compile with OpenSSL applink and pass all tests. Is this PR compatible with the February 2020 applink update? I can try and see what happens.

@bulk88
Copy link
Contributor Author

bulk88 commented Aug 20, 2020

https://rt.cpan.org/Public/Bug/Display.html?id=101638 The jkahrman from February 2020 changes were a hack to get my 2015 patch to compile on newer VCs headers bc the PEB struct is always "undocumented" by MS even though poking in it is done by too many apps over the years and nearly standard by now. His patch will break older/newer VCs without alot of testing. Shining path OpenSSL includes a applink.c in its headers, but it feels like a headache to compile it into a .obj from a random disk location and header search path, makefile complexity. So I copied applink.c into the CPAN XS repo to save the headache of finding the file in the Shining Path headers dir, and copying it or putting an absolute path into the makefile to the headers dir.

@bulk88
Copy link
Contributor Author

bulk88 commented Aug 20, 2020

I use self compiled VC perl. ActivePerl 5.18 and up use GCC like Strawberry Perl. AP 5.16 and older use Visual C. I'm not sure AP any version is appropriate to test with, since all familys of AP have a precompiled binary package manager and Net::SSLEay is shipped as a binary. Mingw/GCC always uses msvcrt.dll as C lib, so im not sure if applink test always fails during ActivePerl's corporate build farm build and the test fail is intentionally ignored, and I'm not sure what happens on strawberry (applink.c is compiled out or test fail ignored by kmx during his build process). Atleast with shining path/stock SSL, the "root .exe" must export the applink symbol/C function callback, but Win32 Perl is not static linked and there is no control over starting .exe of Win32 perl. Its either a P5P tiny stub that calls main() in libperl or its apache.exe or something. There is not really any runtime API in Windows to ask the OS what was the parent dependency of a certain DLL. Dependency walker starts from root .exe and goes down the static dependency tree specified in the PE files, along with runtime function pointer patching to hook GetProcAddress and LoadLibrary and check the return address/caller of both hook functions to find out what the parent DLL is for a runtime dynamic load.

Copy link
Contributor

@h-vn h-vn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently available Shining Light OpenSSL MSI installers use the following installation directories:

  • C:\Program Files\OpenSSL-Win64\
  • C:\Program Files (x86)\OpenSSL-Win32\

At the time of writing, the MSI file names are Win64OpenSSL-1_1_1w.msi, Win64OpenSSL-3_0_12.msi, Win64OpenSSL-3_1_4.msi and Win64OpenSSL-3_2_0.msi. 32bit versions are respectively named Win32OpenSSL-1_1_1w.msi, etc.

In other words, none of the currently available installers use these directories from the commit in this pull request:

  • C:\Program Files\OpenSSL\bin\openssl.exe
  • C:\Program Files\OpenSSL-Win32\bin\openssl.exe

Therefore I'll skip these two directories and add the aforementioned directories that the current installers use. Older Shining Light OpenSSL installers are not available so I'd say it's reasonable to target them anymore.

@h-vn
Copy link
Contributor

h-vn commented Jan 1, 2024

The changes were cherry-picked to pull request #455 and then merged. Some modifications and updates were needed, but most of them were still applied correctly and were up-to-date. Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants