curl with ssl support for win32
2012-10-18 18:32
507 查看
Preprocessor
The following two symbols need to be fed to the preprocessor to enable SSL for libcurl:
(libcurl uses OpenSSL for SSL support)
Alternatively the symbols can be added directly to a file called setup.h in libcurl, but I'm not too happy about modifying code in 3rd party distributions unless I really have to.
Rebuilding the libcurl library, I now got some errors about OpenSSL include files not being found. Naturally, since I haven't set up the OpenSSL distribution properly yet.
Compiling OpenSSL binaries
I downloaded the OpenSSL 0.9.8 source distribution and unpacked it.
In the root of the source distribution there's a file called INSTALL.W32 which describes how to compile the OpenSSL binaries. The build chain requires perl, so I installed the latest version of ActivePerl.
I had some trouble with the build, which might not be applicable to all systems, but I'll go through it here in case somebody experiences the same.
According to INSTALL.W32:
Run the following commandline tasks with current directory set to the source distribution root:
(Where "c:/some/openssl/dir" should be replaced by the dir where OpenSSL should be installed. Don't use spaces in this path. The compilation further ahead will fail in that case)
For me this step was unsuccessful at first, since I lacked the environment variables OSVERSION and TARGETCPU. I set these to 5.1.2600 and x86 respectively. You may get complaint about OSVERSION being "insane", but look closer, this error is for WinCE and doesn't affect the Win32 setup. To get hold of your OS version, run the 'ver' command from a command prompt or run winver.exe.
or
The source now compiles. Took approx 5 minutes on my laptop.
When compilation is completed, the libs or binaries have been placed in:
distroot/out32 - for static library build
or
distroot/out32dll - for DLL build
Building and linking
Now, back to visual studio and point out the libs and include path for headers. The include files are located in distroot/inc32/openssl.
Remember to add libeay32.lib and ssleay32.lib as linker input.
Rebuild the libcurl project.
Error!
Well at least for me with this version of OpenSSL. it complained about a struct typedef in one of the OpenSSL headers. I couldn't find any info on this. After an hour of googling I broke my own principle and commented out the typedef from the OpenSSL header, and luckily libcurl wasn't using that symbol so it built fine.
Update: As pointed out by Jason, this issue seems to have dissapeared as of version 1.0.0a.
Now, for confirming that SSL support is enabled for libcurl, run the following code:
Simple as that.
The following two symbols need to be fed to the preprocessor to enable SSL for libcurl:
USE_SSLEAY USE_OPENSSL
(libcurl uses OpenSSL for SSL support)
Alternatively the symbols can be added directly to a file called setup.h in libcurl, but I'm not too happy about modifying code in 3rd party distributions unless I really have to.
Rebuilding the libcurl library, I now got some errors about OpenSSL include files not being found. Naturally, since I haven't set up the OpenSSL distribution properly yet.
Compiling OpenSSL binaries
I downloaded the OpenSSL 0.9.8 source distribution and unpacked it.
In the root of the source distribution there's a file called INSTALL.W32 which describes how to compile the OpenSSL binaries. The build chain requires perl, so I installed the latest version of ActivePerl.
I had some trouble with the build, which might not be applicable to all systems, but I'll go through it here in case somebody experiences the same.
According to INSTALL.W32:
Run the following commandline tasks with current directory set to the source distribution root:
1> perl Configure VC-WIN32 --prefix=c:/some/openssl/dir
(Where "c:/some/openssl/dir" should be replaced by the dir where OpenSSL should be installed. Don't use spaces in this path. The compilation further ahead will fail in that case)
2> ms\do_ms
For me this step was unsuccessful at first, since I lacked the environment variables OSVERSION and TARGETCPU. I set these to 5.1.2600 and x86 respectively. You may get complaint about OSVERSION being "insane", but look closer, this error is for WinCE and doesn't affect the Win32 setup. To get hold of your OS version, run the 'ver' command from a command prompt or run winver.exe.
3> nmake -f ms\nt.mak (forstatic library)
or
3> nmake -f ms\ntdll.mak (for DLL)
The source now compiles. Took approx 5 minutes on my laptop.
When compilation is completed, the libs or binaries have been placed in:
distroot/out32 - for static library build
or
distroot/out32dll - for DLL build
Building and linking
Now, back to visual studio and point out the libs and include path for headers. The include files are located in distroot/inc32/openssl.
Remember to add libeay32.lib and ssleay32.lib as linker input.
Rebuild the libcurl project.
Error!
Well at least for me with this version of OpenSSL. it complained about a struct typedef in one of the OpenSSL headers. I couldn't find any info on this. After an hour of googling I broke my own principle and commented out the typedef from the OpenSSL header, and luckily libcurl wasn't using that symbol so it built fine.
Update: As pointed out by Jason, this issue seems to have dissapeared as of version 1.0.0a.
Now, for confirming that SSL support is enabled for libcurl, run the following code:
curl_version_info_data * vinfo = curl_version_info( CURLVERSION_NOW ); if( vinfo->features & CURL_VERSION_SSL ) // SSL support enabled else // No SSL
Simple as that.
相关文章推荐
- 解决Curl development headers with SSL support NOT FOUND 问题
- curl with ssl support 编译
- How to build cURL static library with SSL support on Windows
- Building image with support for 3g/4g module and usb tethering
- curl Problem with the SSL CA cert (path? access rights?)
- Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (24.2
- php中curl请求报错:Problem with the SSL CA cert (path? access rights?)
- WCF分布式开发常见错误(24):Could not establish trust relationship for the SSL/TLS secure channel with authority
- Static Equilibrium for a Plate with Support at Three Points
- Using Let’s Encrypt for free SSL Certs with Netscaler
- Creating CustomBinding for WCFBasicHTTP for SSL and BasicAuthentication in BizTalk 转载自:http://geekswithblogs.net/mipsen
- 解决For compliance with existing applications not using SSL the verifyServerCertificate property
- 编译 curl with ssl
- Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (24.2.
- curl call error(77): Problem with the SSL CA cert (path? access rights?)
- git cloning fails with libcurl was built with SSL disabled
- A Bitmap Manipulation Class With Support For Format Conversion, Bitmap Retrieval from a URL, Overlays, etc.
- curl error: Problem with the SSL CA cert (path access rights?) 的解决方法
- Setting up SSL for SCM-Manager with Microsoft CA and TortoiseHg
- WCF interactive with IIS 7 Support for non-http portocals