c++builder 编译 openssl
2016-09-10 18:25
253 查看
原文地址:http://www.rudeserver.com/ssl/openssltutorial.html
防止原文丢失,特在此拷贝一份,thanksMattFlood
NOTES:
Here'sexactlywhatIdidfromstarttofinishinordertobuildasimpleHTTPSclientusingopensslandBorlandC++Builder.InstallingopensslisdocumentedinINSTALL.W32,includedinthesourcedistribution,butI'vedocumentedmyexperience
here.....
YouShouldhaveBorlandC++Builderinstalledonyoursystem(I'musingC++Builder5).
YouShouldhaveautilitytodecode.tar.gzfiles(winzip,zipmagic,tar,gzip,etc...)
Downloadtheopensslsourcefromhere:
http://www.openssl.org/source/
Idownloadedhttp://www.openssl.org/source/openssl-0.9.6c.tar.gz
unzipanduntarthesourcecode.
afterthat,mysourcecodeendedupinafolder:
C:\DocumentsandSettings\poopoohead\Desktop\ssl\openssl\openssl-0.9.6c
YouneedtoinstallActiveStateperlifyoudon'talreadyhaveit...
DownloadthelateststablereleaseActivePerlfromhttp://www.activestate.com/
Whenyouinstallit,justmakesureeveryboxischeckedoneverydialoguethatpopsuptomakesurethe
environmentissetupcompletely
openupacommandprompt(>).
ThisstepistomakesureyouhavepathssetupforBorland'smakeandcompilerprograms.Runthefollowingtwocommandsandmakesuretheyarerecognizedcommands.Ifyoudon'tknowwhatImean-type>dingo666,andyou'llseewhatanunrecognizedcommand
lookslike.Ifthefollowingcommandsareunrecognized,you'llneedtomodify
yoursystem'sPATHvariable.Ididn'thaveto.
>make
>bcc32
Navigatetothebasedirectoryoftheopensslsource
>cdC:\DocumentsandSettings\poopoohead\Desktop\ssl\openssl\openssl-0.9.6c
Runthefollowingtocreateyourmakefile:
>ms\bcb4.bat
runmaketocompletethebuild.
>make-fbcb.mak
ifmakeransuccessfully,youshouldnowhave3newfoldersundertheinstalldir:
inc32(thisiswheretheincludefilesare....)
out32(thisiswherethe.libsare)
tmp32(thisisnothingtobeconcernedwith)
Nowyou'rereadytobuildansslapplication!!
PowerupBorlandC++Builder
Createanewapp(shouldalreadybeanewappreadytoworkwith...)
AddaMemoobjecttothemainform(leavedefaultname:Memo1),thisisjustsowecanseetheresultsortherequest.
Youneedtoaddtheopensslincludedirectoryandlibrariestoyourproject
Fromthemenu:Project->Options(orjusttypeshift+ctrl+F11)
Clickthe"Directories/Conditionals"Tab
Addtheincludedirectory:
clicktheelipses[...]buttontothefarrightof"includepath"
clicktheelipses[...]buttonthatappearsonthepopupdialogthatappears
navigatetoyourinc32folder
makesure"inc32"ishighlighted,NOTthe"openssl"subdirectory.....
click[OK]toselectthefolder
Clickthe[Add]button,then[OK]
Addtheopenssllibrarypath(I'mnotsurethisstepisneccesary,butIdiditanyway....):
Dothesamethingyoudidfortheincludedirectoryabove,adding"out32"to"LibraryPath"
Click[OK]toclosethepropertiesdialog
Nowaddthessllibrariestoyourproject:
Fromthemenu:Project->AddtoProject(orjusttypeshift+F11)
Makesure"FilesofType"issetto"LibrayFile(.lib)"
Navigatetoyourout32folder
selectalllibraryfilesthatappearinthatdirectorylisting,thenclick[Open]button
Addthefollowingincludedirectivestotheapplication:
CreateaSOCKETandconnecttoanhttpsserveronport443likeyounormallywould....
Assumingyoursocketisnamedsock,youthenperformyoursslcommunicationslikethis:
That'sit,buildandruntheprogram...
防止原文丢失,特在此拷贝一份,thanksMattFlood
NOTES:
Here'sexactlywhatIdidfromstarttofinishinordertobuildasimpleHTTPSclientusingopensslandBorlandC++Builder.InstallingopensslisdocumentedinINSTALL.W32,includedinthesourcedistribution,butI'vedocumentedmyexperience
here.....
YouShouldhaveBorlandC++Builderinstalledonyoursystem(I'musingC++Builder5).
YouShouldhaveautilitytodecode.tar.gzfiles(winzip,zipmagic,tar,gzip,etc...)
Downloadtheopensslsourcefromhere:
Idownloaded
unzipanduntarthesourcecode.
afterthat,mysourcecodeendedupinafolder:
C:\DocumentsandSettings\poopoohead\Desktop\ssl\openssl\openssl-0.9.6c
YouneedtoinstallActiveStateperlifyoudon'talreadyhaveit...
DownloadthelateststablereleaseActivePerlfrom
Whenyouinstallit,justmakesureeveryboxischeckedoneverydialoguethatpopsuptomakesurethe
environmentissetupcompletely
openupacommandprompt(>).
ThisstepistomakesureyouhavepathssetupforBorland'smakeandcompilerprograms.Runthefollowingtwocommandsandmakesuretheyarerecognizedcommands.Ifyoudon'tknowwhatImean-type>dingo666,andyou'llseewhatanunrecognizedcommand
lookslike.Ifthefollowingcommandsareunrecognized,you'llneedtomodify
yoursystem'sPATHvariable.Ididn'thaveto.
>make
>bcc32
Navigatetothebasedirectoryoftheopensslsource
>cdC:\DocumentsandSettings\poopoohead\Desktop\ssl\openssl\openssl-0.9.6c
Runthefollowingtocreateyourmakefile:
>ms\bcb4.bat
runmaketocompletethebuild.
>make-fbcb.mak
ifmakeransuccessfully,youshouldnowhave3newfoldersundertheinstalldir:
inc32(thisiswheretheincludefilesare....)
out32(thisiswherethe.libsare)
tmp32(thisisnothingtobeconcernedwith)
Nowyou'rereadytobuildansslapplication!!
PowerupBorlandC++Builder
Createanewapp(shouldalreadybeanewappreadytoworkwith...)
AddaMemoobjecttothemainform(leavedefaultname:Memo1),thisisjustsowecanseetheresultsortherequest.
Youneedtoaddtheopensslincludedirectoryandlibrariestoyourproject
Fromthemenu:Project->Options(orjusttypeshift+ctrl+F11)
Clickthe"Directories/Conditionals"Tab
Addtheincludedirectory:
clicktheelipses[...]buttontothefarrightof"includepath"
clicktheelipses[...]buttonthatappearsonthepopupdialogthatappears
navigatetoyourinc32folder
makesure"inc32"ishighlighted,NOTthe"openssl"subdirectory.....
click[OK]toselectthefolder
Clickthe[Add]button,then[OK]
Addtheopenssllibrarypath(I'mnotsurethisstepisneccesary,butIdiditanyway....):
Dothesamethingyoudidfortheincludedirectoryabove,adding"out32"to"LibraryPath"
Click[OK]toclosethepropertiesdialog
Nowaddthessllibrariestoyourproject:
Fromthemenu:Project->AddtoProject(orjusttypeshift+F11)
Makesure"FilesofType"issetto"LibrayFile(.lib)"
Navigatetoyourout32folder
selectalllibraryfilesthatappearinthatdirectorylisting,thenclick[Open]button
Addthefollowingincludedirectivestotheapplication:
#include<openssl/crypto.h> #include<openssl/x509.h> #include<openssl/pem.h> #include<openssl/ssl.h> #include<openssl/err.h> |
Assumingyoursocketisnamedsock,youthenperformyoursslcommunicationslikethis:
SOCKETsock; //buildregularSOCK_STREAMsockandconnecttoserver //...(I'mnotgoingintothesedetails) //pretendsockisnowconnected.... //here'sthedataitemswe'lluse.... charbuf[1000]; charrequest[1000]; SSL_CTX*ctx; SSL*ssl; interr; //initializeSSLstuff // SSL_load_error_strings(); SSL_library_init(); //buildtheSSLobjects... // ctx=SSL_CTX_new(SSLv2_client_method()); ssl=SSL_new(ctx); //assignthesocketyoucreatedforSSLtouse // SSL_set_fd(ssl,[b]sock); //communicate!! ///////////////////////////////////////////// err=SSL_connect(ssl); sprintf(request, "GET%sHTTP/1.0\r\nHost:%s\r\n\r\n","/", "www.theserver.com"); err=SSL_write(ssl,request,strlen(request)); while(1) { intread_size; read_size=SSL_read(ssl,buf,sizeof(buf)-1); buf[read_size]='\0'; if(read_size>0) { //I'massumingyouhaveaMemoobject //onyourapplicationform... // Memo1->SetSelTextBuf(buf); } else { break; } } //freetheSSLstuff.... // SSL_shutdown(ssl); SSL_free(ssl); SSL_CTX_free(ctx);[/b] |
相关文章推荐
- Linux 从源码编译安装 OpenSSL
- VS2013编译64位OpenSSL(附32位)
- openssl编译
- 安全通信系统--OpenSSL的安装编译、证书生成
- ios 编译openssl支持arm64
- 编译安装带openssl的nginx的方法
- 在Windows下编译OpenSSL(VS2005)【转】
- windows下openssl的编译
- 如何通过Makefile编译iphone的openSSL
- Linux 从源码编译安装 OpenSSL
- Libcurl使用OpenSSL编译出现undefined reference to `COMP_CTX_free'错误备忘
- VS2013中编译openssl的步骤和使用设置
- window下安装openssl1.1.0(以及linux 下源码编译安装)
- 交叉编译开源库 openssl-OpenSSL_1_0_2j
- openssl在arm下的交叉编译
- OpenSSL编译方法
- 交叉编译openssl不修改Makefile的方法
- libevent 配合 openssl android编译配置
- vs2008环境nmake编译 apache 2.2.29 openssl 1.0.1g mod_ssl 不知道如何生成“"..\..\srclib\openssl\inc32\openssl\store.h"”
- Windows环境下使用VS2005编译OpenSSL