简体   繁体   中英

Build native OpenSSL library for WP8 Platform

I am creating Windows phone 8 application.I need to create App which uses compiled OpenSSL library.I was following standard latest library.

I am following INSTALL.W64 steps, as I don't know which INSTALL.* to be used.As my machine is 64 bit I preferred this:

To build for Win64/x64:

1 perl Configure VC-WIN64A
2 ms\\do_win64a
3 nmake -f ms\\ntdll.mak
4 cd out32dll
5 ..\\ms\\test

Using Visual Studio Command Prompt.Upto step 2 is fine.At 3rd step it fails to build and doesn't create library in out32dll Folder.It gives error like:

C:\Program Files (x86)\Windows Phone Kits\8.0\include\windows.h(182) : fatal err
or C1083: Cannot open include file: 'winreg.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
\VC\WPSDK\WP80\BIN\cl.EXE"' : return code '0x2'
Stop.

My question is : Is really OpenSSL supported for Windows Phone Platform .As I seen this which is true/false I am not sure.

Apart from this standard way I also tried this solution.Able to complete steps mentioned in answer.got build compiled in visual studio.Referenced OpenSSLWP8 in Windows Phone 8 Project.Compiled libeay32 .

But when I try to create reference NativeCrypto nc = new NativeCrypto() I get FileNotFoundException in that library.Am I missing something?

Which solution is better or there is any other solution available so that I can build OpenSSL for WP8 .

Any help is appreciated. Thanks.

My question is: Is really OpenSSL supported for Windows Phone Platform. As I seen this which is true/false I am not sure.

Not officially.

I know one of the OpenSSL developers regularly build OpenSSL for Windows 8. I was also able to build for Windows 8. However...

I've got a bunch of patches for Windows RT and Windows Phone. The patches add three new targets, and it don't use VC-WIN64A . The added targets are VC-WP8-X86 , VC-WP8-ARM , and VC-WINRT-ARM .

I added two new defines ( OPENSSL_SYS_WINRT and OPENSSL_SYS_WINPHONE ) so a lot of this went on:

-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(OPENSSL_SYS_WINCE) &&
     !defined(OPENSSL_SYS_WINRT) && !defined(OPENSSL_SYS_WINPHONE)

The cflags needed some tuning. For example, here's from Windows RT:

+    $base_cflags.= " /D WINAPI_FAMILY=WINAPI_PARTITION_APP";
+    $base_cflags.= " /FI SDKDDKVer.h /FI winapifamily.h";

And Windows Phone:

+    $base_cflags.= " /D WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP";
+    $base_cflags.= " /AI\"$ENV{'WINDOWSMETADATA'}\"";
+    $base_cflags.= " /FI SDKDDKVer.h /FI winapifamily.h";

The Windows RT target is severely crippled. As an example of how bad things are on Windows RT: the target needed both -DOPENSSL_NO_SOCK and -DOPENSSL_NO_DGRAM because applications are not allowed to access the socket API. That makes it pretty useless SSL library since TCP and UDP was gutted.

The Windows Phone target is a little better. Windows Phone allows access to the socket API (so TCP and UDP are available), but the random number generator seeding is broken. Its broken because Microsoft does not provide CryptGenRandom or the older Win32 screen APIs that were used to scrape state. Application will need to explicitly seed from RNGCryptoServiceProvider .

You can see traces of my suffering on Stack Overflow. For example, Windows RT: where is sockaddr_in? .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM