Open SSL Development Environment Configuration

Source: Internet
Author: User
Tags install openssl
Open SSL Development Environment Configuration

Last update date:2014-05-13

Prerequisites:Basic use of Visual Studio and basic use of cent OS

Environment:Windows 8.1 64bit English, Visual Studio 2013 professional update1 English, ActivePerl 5.16.3, openssl-1.0.1g, cent OS 6.5 (32-bit), openssl-1.0.1e

 

Configure the Open SSL development environment in Windows to compile a 32-bit Open SSL dependency Library

[1] download and install ActivePerl 5.16.3 for Windows (64-bit, x64) from the active Perl Official Website

[2] Download openssl-1.0.1g.tar.gz from open ssl to D: \ SDK

You can also decompress the package to another path.

 

[3] Start the [visual studiotools]-> [vs2013 x86 native tools command prompt] program, and enter the D: \ SDK \ openssl_1.0.1g directory to run the command

Perlconfigure VC-WIN32 no-ASM

Do_nasm.bat and other files are generated in the MS subdirectory.

 

[4] Calling the following command in the current directory (D: \ SDK \ sopenssl-1.0.1g)

Ms \ do_nasm.bat
Generate the NT. Make and NTDLL. Make files in the MS subdirectory of the current directory.

 

[5] run the following command to generate a static library in the out32 directory

Nmake-F Ms \ nt. Mak

You can also use the following command to generate a dynamic library in the out32dll directory.

Nmake-F Ms \ NTDLL. Mak

[6] Create A Win32 console project under Visual Studio 2013. do not generate code automatically, add the source. cpp file, and use the following code to test whether the Open SSL development environment is normal.

#include <string> #include <iomanip>#include <iostream> #include <openssl/md5.h>using namespace std;#ifdef WIN32#pragma comment(lib, "libeay32.lib")#pragma comment(lib, "ssleay32.lib")#endifint main(int argc, char* argv[]){std::string str = "1234";unsigned char md[MD5_DIGEST_LENGTH];char tmp[3] = { 0 };MD5((const unsigned char*)str.c_str(), str.size(), md);for (int i = 0; i < MD5_DIGEST_LENGTH; i++){cout<<setw(2)<<setfill('0')<

After the test is complete, you can compile the Open SSL 64-bit dynamic library and static library files in a similar way.

Compile the 64-bit Open SSL dependency Library

Start the [Visual Studio Tools]-> [vs2013 x64 native tools command prompt] program and go to the D: \ SDK \ openssl_1.0.1g directory to run the following six commands:

Perlconfigure VC-WIN64A no-ASM

Ms \ do_win64a.bat

Nmake-F Ms \ nt. Mak clean

Nmake-F Ms \ NTDLL. Mak clean

Nmake-F Ms \ nt. Mak

Nmake-F Ms \ NTDLL. Mak

Because the generated openssl64-bit dependent libraries have the same name and location as the 32-bit dependent libraries, we only need, on the [configulation manager] of the project properties page, change the platform property to x64 to call the OpenSSL 64-bit dependency library. The "clean" parameter in the above command is used to clear the original 32-bit files, otherwise nmake will fail. Similarly, the "clean" parameter is also used to change the 64-bit dependency library back to 32-bit files.

You can also use the following two commands to test whether the generated Open SSL static library and dynamic library are normal.

Nmake-F Ms \ nt. Mak Test

Nmake-F Ms \ NTDLL. Mak Test

 

To place the Win32 dependency library generated by Open SSL in a specified place, refer to the following command:

Perl configure VC-WIN32 -- prefix = F:/OpenSSL

 

Install the Open SSL development environment in cent OS

Use the following two commands to install Open SSL

Yum install OpenSSL

Yum install OpenSSL-devel

Run the following command to view the Open SSL installation location:

Whereis OpenSSL

In Windows, libeay32.lib and ssleay32.lib correspond to libcrypto. So and libssl. So files in Linux respectively. They are in the/usr/lib path by default, and the header files are in the/usr/incude directory.

After the above source code is copied to cent OS, the cmake tool is used to compile and run successfully.

The following is a list of cmakelists.txt files.

# Set the project name Project (openssltutorial1) # The minimum cmake version is 2.8cmake _ minimum_required (version 2.8) # Add the header file search path include_directories (/usr/local/include) # Add the library file search path link_directories (/usr/local/LIB) # store the names of all source files in the current directory in the variable dir_srcs aux_source_directory (. dir_srcs) # used to specify the source file source1 source2... Sourcen (defined in the dir_srcs variable) # compile an executable file named openssltutorial1add_executable (openssltutorial1 $ {dir_srcs }) # Add the Link Library required to compile the executable program, and separate multiple links with spaces. # The first parameter is the name of the executable program, the second start is the dependent library target_link_libraries (openssltutorial1 SSL crypto)

The libcrypto. So file implements various encryption algorithms. OpenSSL is used to implement SSL, tlsand S/MIME protocols, and is also used for encryption standards such as SSH and openpgp.

The libssl. So library file implements SSL (thesecure Sockets Layer) v2/V3 and TLS (Transport Layer Security) protocols. TLS and SSL encrypt network connections at the transport layer.

Additional reading materials

Call OpenSSL to implement digital signature function routine (1)

Http://blog.csdn.net/lee353086/article/details/7489863

Call OpenSSL to implement digital signature function routine (2)

Http://blog.csdn.net/lee353086/article/details/7489870

Compile OpenSSL under vc2008

Http://blog.csdn.net/lee353086/article/details/7378835

Compiling OpenSSL with vs2010 in 64-bit win7

Http://blog.csdn.net/henter/article/details/8364532

Wchar_t Problems

Http://bbs.chinaunix.net/archiver? Tid-1350913.html

Centos software installation methods: rpm and yum

Http://www.discuz.net/thread-3513163-1-1.html

 



Open SSL Development Environment Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.