Skip to content

Commit

Permalink
ssl 客户端测试例子完善
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshuxin committed Aug 23, 2014
1 parent 188da0e commit b974f8d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib_acl_cpp/lib_acl_cpp_vc2012.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y</Command>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;USE_WIN_ICONV;HAS_SQLITE;HAS_MYSQL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;USE_WIN_ICONV;HAS_SQLITE;HAS_MYSQL;HAS_POLARSSL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>acl_stdafx.hpp</PrecompiledHeaderFile>
Expand Down
27 changes: 13 additions & 14 deletions lib_acl_cpp/samples/ssl_client/ssl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ static void test0(int i)
acl::string addr("127.0.0.1:441");
if (client.open(addr.c_str(), 60, 60) == false)
{
std::cout << "connect " << addr.c_str() << " error!" << std::endl;
std::cout << "connect " << addr.c_str()
<< " error!" << std::endl;
return;
}

acl::polarssl_io* ssl = new acl::polarssl_io(__ssl_conf, false);
if (client.setup_hook(ssl) == ssl)
{
std::cout << "open ssl " << addr.c_str() << " error!" << std::endl;
std::cout << "open ssl " << addr.c_str()
<< " error!" << std::endl;
ssl->destroy();
return;
}
Expand All @@ -38,14 +40,16 @@ static void test0(int i)
line[1022] = '\n';
if (client.write(line, strlen(line)) == -1)
{
std::cout << "write to " << addr.c_str() << " error!" << std::endl;
std::cout << "write to " << addr.c_str()
<< " error!" << std::endl;
return;
}

size_t n = sizeof(line);
if (client.gets(line, &n) == false)
{
std::cout << "gets from " << addr.c_str() << " error!" << std::endl;
std::cout << "gets from " << addr.c_str()
<< " error!" << std::endl;
return;
}
if (i < 10)
Expand Down Expand Up @@ -232,16 +236,11 @@ int main(int argc, char* argv[])
// 126 的 SSL 传输时当 HTTP 请求头中的 Host 值为 mail.126.com:443 时其 nginx
// 会报错,只能是:Host: mail.126.com,土鳖

if (0)
{
test1("mail.126.com", 443, false, true);
test2("mail.126.com", 443, false, true);
test2("mail.qq.com", 443, false, true);
test2("mail.sohu.com", 443, false, true);
test2("mail.sina.com.cn", 443, false, true);
}
else
test2("mm.263.com", 1443, false, true);
test1("mail.126.com", 443, false, true);
test2("mail.126.com", 443, false, true);
test2("mail.qq.com", 443, false, true);
test2("mail.sohu.com", 443, false, true);
test2("mail.sina.com.cn", 443, false, true);

printf("Over, enter any key to exit!\n");
getchar();
Expand Down
2 changes: 1 addition & 1 deletion lib_acl_cpp/samples/ssl_client/ssl_client_vc2012.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>polarssl.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>ws2_32.lib;lib_acl_vc2012.lib;lib_protocol_vc2012.lib;lib_acl_cpp_vc2012.lib;polarssl.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)ssl_client.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib\win32;..\..\..\dist\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
Expand Down
9 changes: 9 additions & 0 deletions resource/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
һ���� WIN32 ƽ̨����α��� polarssl.1.2.11
1��������� VC2010 ���루���� VC2012 ��ʱ��Ҫ���¹����ļ���
2����ʹ�� ACL �ľ�̬�ⷽʽ���� polarssl
Ҳ������þ�̬����뷽ʽ���磺Multi-threaded Debug (/MTd) �� Multi-threaded
(/MT)��
3�������� lib_acl_cpp/src/stream/polarssl_io.cpp ��ʹ�� havege_init
����������㷨������� include/polarssl/config.h �У��� "#define
POLARSSL_HAVEGE_C" �ı��뿪��

0 comments on commit b974f8d

Please sign in to comment.