c++builder 编译 openssl
来源:互联网 发布:淘宝卖大牌瑕疵化妆品 编辑:程序博客网 时间:2024/05/21 16:18
原文地址:http://www.rudeserver.com/ssl/openssltutorial.html
防止原文丢失,特在此拷贝一份,thanks Matt Flood
NOTES:
Here's exactly what I did from start to finish in order to build a simple HTTPS client using openssl and Borland C++ Builder. Installing openssl is documented in INSTALL.W32, included in the source distribution, but I've documented my experience here.....
- You Should have Borland C++ Builder installed on your system (I'm using C++ Builder 5).
- You Should have a utility to decode .tar.gz files (winzip,zipmagic, tar, gzip, etc...)
- Download the openssl source from here:
- http://www.openssl.org/source/
- I downloaded http://www.openssl.org/source/openssl-0.9.6c.tar.gz
- unzip and untar the sourcecode.
- after that, my source code ended up in a folder:
C:\Documents and Settings\poopoohead\Desktop\ssl\openssl\openssl-0.9.6c
- after that, my source code ended up in a folder:
- You need to install ActiveState perl if you don't already have it...
- Download the latest stable release ActivePerl from http://www.activestate.com/
- When you install it, just make sure every box is checked on every dialogue that pops up to make sure the
environment is set up completely
- open up a command prompt (>).
- This step is to make sure you have paths set up for Borland's make and compiler programs. Run the following two commands and make sure they are recognized commands. If you don't know what I mean - type >dingo666, and you'll see what an unrecognized command looks like. If the following commands are unrecognized, you'll need to modify
your system's PATH variable. I didn't have to.- >make
- >bcc32
- Navigate to the base directory of the openssl source
- >cd C:\Documents and Settings\poopoohead\Desktop\ssl\openssl\openssl-0.9.6c
- Run the following to create your makefile:
- >ms\bcb4.bat
- run make to complete the build.
- >make -f bcb.mak
- if make ran successfully, you should now have 3 new folders under the install dir:
- inc32 (this is where the include files are....)
- out32 (this is where the .libs are)
- tmp32 (this is nothing to be concerned with)
- Now you're ready to build an ssl application!!
- Power up Borland C++ Builder
- Create a new app (should already be a new app ready to work with...)
- Add a Memo object to the main form (leave default name: Memo1), this is just so we can see the results or the request.
- You need to add the openssl include directory and libraries to your project
- From the menu: Project->Options (or just type shift + ctrl + F11)
- Click the "Directories/Conditionals" Tab
- Add the include directory:
- click the elipses [...] button to the far right of "include path"
- click the elipses [...] button that appears on the pop up dialog that appears
- navigate to your inc32 folder
- make sure "inc32" is highlighted, NOT the "openssl" subdirectory.....
- click [OK] to select the folder
- Click the [Add] button, then [OK]
- Add the openssl library path (I'm not sure this step is neccesary, but I did it anyway....):
- Do the same thing you did for the include directory above, adding "out32" to "Library Path"
- Click [OK] to close the properties dialog
- Now add the ssl libraries to your project:
- From the menu: Project->Add to Project (or just type shift + F11)
- Make sure "Files of Type" is set to "Libray File (.lib)"
- Navigate to your out32 folder
- select all library files that appear in that directory listing, then click [Open] button
- Add the following include directives to the application:#include <openssl/crypto.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/err.h> - Create a SOCKET and connect to an https server on port 443 like you normally would....
- Assuming your socket is named sock, you then perform your ssl communications like this:
SOCKET sock; // build regular SOCK_STREAM sock and connect to server // ... (I'm not going into these details) // pretend sock is now connected.... // here's the data items we'll use.... char buf[1000]; char request[1000]; SSL_CTX *ctx; SSL *ssl; int err; // initialize SSL stuff // SSL_load_error_strings(); SSL_library_init(); // build the SSL objects... // ctx=SSL_CTX_new(SSLv2_client_method()); ssl=SSL_new(ctx); // assign the socket you created for SSL to use // SSL_set_fd(ssl, sock); // communicate!! ///////////////////////////////////////////// err=SSL_connect(ssl); sprintf(request, "GET %s HTTP/1.0\r\nHost: %s\r\n\r\n","/" , "www.theserver.com"); err=SSL_write(ssl, request, strlen(request)); while(1) { int read_size; read_size=SSL_read(ssl, buf, sizeof(buf)-1); buf[read_size]='\0'; if(read_size > 0) { // I'm assuming you have a Memo object //on your application form... // Memo1->SetSelTextBuf(buf); } else { break; } } // free the SSL stuff.... // SSL_shutdown(ssl); SSL_free(ssl); SSL_CTX_free(ctx);
- That's it, build and run the program...
0 0
- c++builder 编译 openssl
- c++builder 2010 with OpenSSL
- c++builder编译可执行文件
- 编译openssl 1.0.0.c
- vs2010 编译 openssl-1.0.1c
- Openssl 1.1.0C VS2013编译
- 交叉编译OpenSSL和paho.mqtt.c
- Borland C++Builder 编译ACE经验
- 在命令行下编译C++Builder工程
- 命令行编译C++Builder/Delphi项目
- C++Builder编译MFC程序的设置
- c++Builder xe5 编译输出路径
- C++Builder中编译MFC类库
- C++Builder 10.2编译android应用问题解决
- openssl编译
- openssl编译
- 编译OpenSSL
- 编译OpenSSL
- ButterKnife使用详解
- 写给女孩:二十岁之后的每一年都很重要
- Java - list 遍历方式
- 希尔排序
- 简单一行代码解决流读取导致StringBuilder.toString()乱码问题
- c++builder 编译 openssl
- ios 热修复的方式
- HDU 5873 2016 ACM/ICPC Asia Regional Dalian Online 1006 Football Games
- 有关lrecycleview的介绍
- opencv 单目,双目棋盘标定总结与自动优化程序
- 在eclipse上安装tomcat插件
- 有符号数除以非2的幂
- 配置shadowsocks服务端
- 1073. Scientific Notation (20)