NetSSL_OpenSSL: complete merge to 1.4.2

This commit is contained in:
Marian Krivos
2011-09-14 18:17:35 +00:00
parent bcf1d5b6a7
commit 56c6a4f758
79 changed files with 16086 additions and 10265 deletions

View File

@@ -1,27 +1,27 @@
# #
# Makefile # Makefile
# #
# $Id: //poco/Main/template/library.make#2 $ # $Id: //poco/Main/template/library.make#2 $
# #
# Makefile for Poco NetSSL_OpenSSL # Makefile for Poco NetSSL_OpenSSL
# #
include $(POCO_BASE)/build/rules/global include $(POCO_BASE)/build/rules/global
SYSLIBS += -lssl -lcrypto SYSLIBS += -lssl -lcrypto
objects = AcceptCertificateHandler CertificateHandlerFactory \ objects = AcceptCertificateHandler RejectCertificateHandler ConsoleCertificateHandler \
CertificateHandlerFactoryMgr ConsoleCertificateHandler \ CertificateHandlerFactory CertificateHandlerFactoryMgr \
Context HTTPSClientSession HTTPSStreamFactory HTTPSSessionInstantiator \ Context HTTPSClientSession HTTPSStreamFactory HTTPSSessionInstantiator \
InvalidCertificateHandler KeyConsoleHandler \ InvalidCertificateHandler KeyConsoleHandler \
KeyFileHandler PrivateKeyFactory PrivateKeyFactoryMgr \ KeyFileHandler PrivateKeyFactory PrivateKeyFactoryMgr \
PrivateKeyPassphraseHandler SecureServerSocket SecureServerSocketImpl \ PrivateKeyPassphraseHandler SecureServerSocket SecureServerSocketImpl \
SecureSocketImpl SecureStreamSocket SecureStreamSocketImpl \ SecureSocketImpl SecureStreamSocket SecureStreamSocketImpl \
SSLException SSLManager Utility VerificationErrorArgs \ SSLException SSLManager Utility VerificationErrorArgs \
X509Certificate X509Certificate Session SecureSMTPClientSession
target = PocoNetSSL target = PocoNetSSL
target_version = $(LIBVERSION) target_version = $(LIBVERSION)
target_libs = PocoNet PocoCrypto PocoUtil PocoFoundation target_libs = PocoNet PocoCrypto PocoUtil PocoFoundation
include $(POCO_BASE)/build/rules/lib include $(POCO_BASE)/build/rules/lib

View File

@@ -0,0 +1,60 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetSSL_OpenSSL", "NetSSL_OpenSSL_vs100.vcxproj", "{5AECC55E-A469-11DA-8DA6-005056C00008}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs100.vcxproj", "{B2B88092-5BCE-4AC0-941E-88167138B4A7}"
ProjectSection(ProjectDependencies) = postProject
{5AECC55E-A469-11DA-8DA6-005056C00008} = {5AECC55E-A469-11DA-8DA6-005056C00008}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug_shared|Win32 = debug_shared|Win32
release_shared|Win32 = release_shared|Win32
debug_static_mt|Win32 = debug_static_mt|Win32
release_static_mt|Win32 = release_static_mt|Win32
debug_static_md|Win32 = debug_static_md|Win32
release_static_md|Win32 = release_static_md|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_shared|Win32.Build.0 = debug_shared|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_shared|Win32.Deploy.0 = debug_shared|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_shared|Win32.ActiveCfg = release_shared|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_shared|Win32.Build.0 = release_shared|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_shared|Win32.Deploy.0 = release_shared|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_md|Win32.Deploy.0 = debug_static_md|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_md|Win32.Build.0 = release_static_md|Win32
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_md|Win32.Deploy.0 = release_static_md|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_shared|Win32.Build.0 = debug_shared|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_shared|Win32.Deploy.0 = debug_shared|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_shared|Win32.ActiveCfg = release_shared|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_shared|Win32.Build.0 = release_shared|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_shared|Win32.Deploy.0 = release_shared|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_md|Win32.Deploy.0 = debug_static_md|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_md|Win32.Build.0 = release_static_md|Win32
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_md|Win32.Deploy.0 = release_static_md|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,330 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="debug_shared|Win32">
<Configuration>debug_shared</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_md|Win32">
<Configuration>debug_static_md</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_mt|Win32">
<Configuration>debug_static_mt</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_shared|Win32">
<Configuration>release_shared</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_md|Win32">
<Configuration>release_static_md</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_mt|Win32">
<Configuration>release_static_mt</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>NetSSL_OpenSSL</ProjectName>
<ProjectGuid>{5AECC55E-A469-11DA-8DA6-005056C00008}</ProjectGuid>
<RootNamespace>NetSSL_OpenSSL</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">..\bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">..\bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">..\lib\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">..\lib\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">..\lib\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">..\lib\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">PocoNetSSLd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">PocoNetSSLmdd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">PocoNetSSLmtd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">PocoNetSSL</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">PocoNetSSLmd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">PocoNetSSLmt</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NetSSL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>..\bin\PocoNetSSLd.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>..\bin\PocoNetSSLd.pdb</ProgramDatabaseFile>
<AdditionalLibraryDirectories>..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<ImportLibrary>..\lib\PocoNetSSLd.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NetSSL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>..\bin\PocoNetSSL.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<ImportLibrary>..\lib\PocoNetSSL.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<ProgramDataBaseFileName>..\lib\PocoNetSSLmtd.pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Lib>
<OutputFile>..\lib\PocoNetSSLmtd.lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Lib>
<OutputFile>..\lib\PocoNetSSLmt.lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<ProgramDataBaseFileName>..\lib\PocoNetSSLmdd.pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Lib>
<OutputFile>..\lib\PocoNetSSLmdd.lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<ProgramDataBaseFileName>..\lib\PocoNetSSLmd.pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Lib>
<AdditionalDependencies>libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>..\lib\PocoNetSSLmd.lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="include\Poco\Net\AcceptCertificateHandler.h"/>
<ClInclude Include="include\Poco\Net\CertificateHandlerFactory.h"/>
<ClInclude Include="include\Poco\Net\CertificateHandlerFactoryMgr.h"/>
<ClInclude Include="include\Poco\Net\ConsoleCertificateHandler.h"/>
<ClInclude Include="include\Poco\Net\Context.h"/>
<ClInclude Include="include\Poco\Net\InvalidCertificateHandler.h"/>
<ClInclude Include="include\Poco\Net\KeyConsoleHandler.h"/>
<ClInclude Include="include\Poco\Net\KeyFileHandler.h"/>
<ClInclude Include="include\Poco\Net\NetSSL.h"/>
<ClInclude Include="include\Poco\Net\PrivateKeyFactory.h"/>
<ClInclude Include="include\Poco\Net\PrivateKeyFactoryMgr.h"/>
<ClInclude Include="include\Poco\Net\PrivateKeyPassphraseHandler.h"/>
<ClInclude Include="include\Poco\Net\RejectCertificateHandler.h"/>
<ClInclude Include="include\Poco\Net\Session.h"/>
<ClInclude Include="include\Poco\Net\SSLException.h"/>
<ClInclude Include="include\Poco\Net\SSLManager.h"/>
<ClInclude Include="include\Poco\Net\Utility.h"/>
<ClInclude Include="include\Poco\Net\VerificationErrorArgs.h"/>
<ClInclude Include="include\Poco\Net\X509Certificate.h"/>
<ClInclude Include="include\Poco\Net\HTTPSClientSession.h"/>
<ClInclude Include="include\Poco\Net\HTTPSSessionInstantiator.h"/>
<ClInclude Include="include\Poco\Net\HTTPSStreamFactory.h"/>
<ClInclude Include="include\Poco\Net\SecureServerSocket.h"/>
<ClInclude Include="include\Poco\Net\SecureServerSocketImpl.h"/>
<ClInclude Include="include\Poco\Net\SecureSocketImpl.h"/>
<ClInclude Include="include\Poco\Net\SecureStreamSocket.h"/>
<ClInclude Include="include\Poco\Net\SecureStreamSocketImpl.h"/>
<ClInclude Include="include\Poco\Net\SecureSMTPClientSession.h"/>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\AcceptCertificateHandler.cpp"/>
<ClCompile Include="src\CertificateHandlerFactory.cpp"/>
<ClCompile Include="src\CertificateHandlerFactoryMgr.cpp"/>
<ClCompile Include="src\ConsoleCertificateHandler.cpp"/>
<ClCompile Include="src\Context.cpp"/>
<ClCompile Include="src\InvalidCertificateHandler.cpp"/>
<ClCompile Include="src\KeyConsoleHandler.cpp"/>
<ClCompile Include="src\KeyFileHandler.cpp"/>
<ClCompile Include="src\PrivateKeyFactory.cpp"/>
<ClCompile Include="src\PrivateKeyFactoryMgr.cpp"/>
<ClCompile Include="src\PrivateKeyPassphraseHandler.cpp"/>
<ClCompile Include="src\RejectCertificateHandler.cpp"/>
<ClCompile Include="src\Session.cpp"/>
<ClCompile Include="src\SSLException.cpp"/>
<ClCompile Include="src\SSLManager.cpp"/>
<ClCompile Include="src\Utility.cpp"/>
<ClCompile Include="src\VerificationErrorArgs.cpp"/>
<ClCompile Include="src\X509Certificate.cpp"/>
<ClCompile Include="src\HTTPSClientSession.cpp"/>
<ClCompile Include="src\HTTPSSessionInstantiator.cpp"/>
<ClCompile Include="src\HTTPSStreamFactory.cpp"/>
<ClCompile Include="src\SecureServerSocket.cpp"/>
<ClCompile Include="src\SecureServerSocketImpl.cpp"/>
<ClCompile Include="src\SecureSocketImpl.cpp"/>
<ClCompile Include="src\SecureStreamSocket.cpp"/>
<ClCompile Include="src\SecureStreamSocketImpl.cpp"/>
<ClCompile Include="src\SecureSMTPClientSession.cpp"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"/>
</Project>

View File

@@ -0,0 +1,210 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="SSLCore">
<UniqueIdentifier>{7dfc0f8e-4040-493b-a52c-1cf7016ce630}</UniqueIdentifier>
</Filter>
<Filter Include="SSLCore\Header Files">
<UniqueIdentifier>{cbdd06c0-5e7c-4872-8e94-9aec1737ccb4}</UniqueIdentifier>
</Filter>
<Filter Include="SSLCore\Source Files">
<UniqueIdentifier>{faed5eaa-7df0-43b2-9e14-dda9415e3119}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient">
<UniqueIdentifier>{a101ea91-6383-421c-8ffe-b72ad78e9f47}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient\Header Files">
<UniqueIdentifier>{2d63ba0b-8c3c-4aa4-9c2d-59650588ca07}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient\Source Files">
<UniqueIdentifier>{95d3f434-eddb-4bd0-97e0-84151a49d420}</UniqueIdentifier>
</Filter>
<Filter Include="SSLSockets">
<UniqueIdentifier>{945cbc89-8697-4fc7-8972-1e94618df936}</UniqueIdentifier>
</Filter>
<Filter Include="SSLSockets\Header Files">
<UniqueIdentifier>{aacbaf1d-ecf9-4cd8-a748-ff96a2f113a8}</UniqueIdentifier>
</Filter>
<Filter Include="SSLSockets\Source Files">
<UniqueIdentifier>{1eca506b-2ddc-43e8-be2d-d2218d6e46b9}</UniqueIdentifier>
</Filter>
<Filter Include="Mail">
<UniqueIdentifier>{0be91609-0b40-4f0a-a534-d869eacf28aa}</UniqueIdentifier>
</Filter>
<Filter Include="Mail\Header Files">
<UniqueIdentifier>{7630e880-e526-4c53-a456-0afebff3ee52}</UniqueIdentifier>
</Filter>
<Filter Include="Mail\Source Files">
<UniqueIdentifier>{377a0f28-f2ba-421a-bb23-cf90baa8e1fa}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\Poco\Net\AcceptCertificateHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\CertificateHandlerFactory.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\CertificateHandlerFactoryMgr.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\ConsoleCertificateHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\Context.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\InvalidCertificateHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\KeyConsoleHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\KeyFileHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\NetSSL.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\PrivateKeyFactory.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\PrivateKeyFactoryMgr.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\PrivateKeyPassphraseHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\RejectCertificateHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\Session.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SSLException.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SSLManager.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\Utility.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\VerificationErrorArgs.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\X509Certificate.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\HTTPSClientSession.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\HTTPSSessionInstantiator.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\HTTPSStreamFactory.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureServerSocket.h">
<Filter>SSLSockets\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureServerSocketImpl.h">
<Filter>SSLSockets\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureSocketImpl.h">
<Filter>SSLSockets\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureStreamSocket.h">
<Filter>SSLSockets\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureStreamSocketImpl.h">
<Filter>SSLSockets\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureSMTPClientSession.h">
<Filter>Mail\Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\AcceptCertificateHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\CertificateHandlerFactory.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\CertificateHandlerFactoryMgr.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\ConsoleCertificateHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Context.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\InvalidCertificateHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\KeyConsoleHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\KeyFileHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\PrivateKeyFactory.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\PrivateKeyFactoryMgr.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\PrivateKeyPassphraseHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\RejectCertificateHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Session.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SSLException.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SSLManager.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Utility.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\VerificationErrorArgs.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\X509Certificate.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSClientSession.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSSessionInstantiator.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSStreamFactory.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureServerSocket.cpp">
<Filter>SSLSockets\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureServerSocketImpl.cpp">
<Filter>SSLSockets\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureSocketImpl.cpp">
<Filter>SSLSockets\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureStreamSocket.cpp">
<Filter>SSLSockets\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureStreamSocketImpl.cpp">
<Filter>SSLSockets\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureSMTPClientSession.cpp">
<Filter>Mail\Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -0,0 +1,60 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetSSL_OpenSSL", "NetSSL_OpenSSL_x64_vs100.vcxproj", "{5AECC55E-A469-11DA-8DA6-005056C00008}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_x64_vs100.vcxproj", "{B2B88092-5BCE-4AC0-941E-88167138B4A7}"
ProjectSection(ProjectDependencies) = postProject
{5AECC55E-A469-11DA-8DA6-005056C00008} = {5AECC55E-A469-11DA-8DA6-005056C00008}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug_shared|x64 = debug_shared|x64
debug_static_md|x64 = debug_static_md|x64
debug_static_mt|x64 = debug_static_mt|x64
release_shared|x64 = release_shared|x64
release_static_md|x64 = release_static_md|x64
release_static_mt|x64 = release_static_mt|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_shared|x64.ActiveCfg = debug_shared|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_shared|x64.Build.0 = debug_shared|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_shared|x64.Deploy.0 = debug_shared|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_md|x64.ActiveCfg = debug_static_md|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_md|x64.Build.0 = debug_static_md|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_md|x64.Deploy.0 = debug_static_md|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_mt|x64.ActiveCfg = debug_static_mt|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_mt|x64.Build.0 = debug_static_mt|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.debug_static_mt|x64.Deploy.0 = debug_static_mt|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_shared|x64.ActiveCfg = release_shared|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_shared|x64.Build.0 = release_shared|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_shared|x64.Deploy.0 = release_shared|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_md|x64.ActiveCfg = release_static_md|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_md|x64.Build.0 = release_static_md|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_md|x64.Deploy.0 = release_static_md|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_mt|x64.ActiveCfg = release_static_mt|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_mt|x64.Build.0 = release_static_mt|x64
{5AECC55E-A469-11DA-8DA6-005056C00008}.release_static_mt|x64.Deploy.0 = release_static_mt|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_shared|x64.ActiveCfg = debug_shared|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_shared|x64.Build.0 = debug_shared|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_shared|x64.Deploy.0 = debug_shared|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_md|x64.ActiveCfg = debug_static_md|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_md|x64.Build.0 = debug_static_md|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_md|x64.Deploy.0 = debug_static_md|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_mt|x64.ActiveCfg = debug_static_mt|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_mt|x64.Build.0 = debug_static_mt|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.debug_static_mt|x64.Deploy.0 = debug_static_mt|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_shared|x64.ActiveCfg = release_shared|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_shared|x64.Build.0 = release_shared|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_shared|x64.Deploy.0 = release_shared|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_md|x64.ActiveCfg = release_static_md|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_md|x64.Build.0 = release_static_md|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_md|x64.Deploy.0 = release_static_md|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_mt|x64.ActiveCfg = release_static_mt|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_mt|x64.Build.0 = release_static_mt|x64
{B2B88092-5BCE-4AC0-941E-88167138B4A7}.release_static_mt|x64.Deploy.0 = release_static_mt|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,328 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="debug_shared|x64">
<Configuration>debug_shared</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_md|x64">
<Configuration>debug_static_md</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_mt|x64">
<Configuration>debug_static_mt</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_shared|x64">
<Configuration>release_shared</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_md|x64">
<Configuration>release_static_md</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_mt|x64">
<Configuration>release_static_mt</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>NetSSL_OpenSSL</ProjectName>
<ProjectGuid>{5AECC55E-A469-11DA-8DA6-005056C00008}</ProjectGuid>
<RootNamespace>NetSSL_OpenSSL</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">..\bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">..\bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">..\lib64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">..\lib64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">..\lib64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">..\lib64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">PocoNetSSL64d</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">PocoNetSSLmdd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">PocoNetSSLmtd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">PocoNetSSL64</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">PocoNetSSLmd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">PocoNetSSLmt</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NetSSL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>..\bin64\PocoNetSSL64d.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>..\bin64\PocoNetSSL64d.pdb</ProgramDatabaseFile>
<AdditionalLibraryDirectories>..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<ImportLibrary>..\lib64\PocoNetSSLd.lib</ImportLibrary>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NetSSL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>..\bin64\PocoNetSSL64.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<ImportLibrary>..\lib64\PocoNetSSL.lib</ImportLibrary>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<ProgramDataBaseFileName>..\lib64\PocoNetSSLmtd.pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Lib>
<OutputFile>..\lib64\PocoNetSSLmtd.lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Lib>
<OutputFile>..\lib64\PocoNetSSLmt.lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<ProgramDataBaseFileName>..\lib64\PocoNetSSLmdd.pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Lib>
<OutputFile>..\lib64\PocoNetSSLmdd.lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\Foundation\include;..\Net\include;..\Util\include;..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Lib>
<OutputFile>..\lib64\PocoNetSSLmd.lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="include\Poco\Net\AcceptCertificateHandler.h"/>
<ClInclude Include="include\Poco\Net\CertificateHandlerFactory.h"/>
<ClInclude Include="include\Poco\Net\CertificateHandlerFactoryMgr.h"/>
<ClInclude Include="include\Poco\Net\ConsoleCertificateHandler.h"/>
<ClInclude Include="include\Poco\Net\Context.h"/>
<ClInclude Include="include\Poco\Net\InvalidCertificateHandler.h"/>
<ClInclude Include="include\Poco\Net\KeyConsoleHandler.h"/>
<ClInclude Include="include\Poco\Net\KeyFileHandler.h"/>
<ClInclude Include="include\Poco\Net\NetSSL.h"/>
<ClInclude Include="include\Poco\Net\PrivateKeyFactory.h"/>
<ClInclude Include="include\Poco\Net\PrivateKeyFactoryMgr.h"/>
<ClInclude Include="include\Poco\Net\PrivateKeyPassphraseHandler.h"/>
<ClInclude Include="include\Poco\Net\RejectCertificateHandler.h"/>
<ClInclude Include="include\Poco\Net\Session.h"/>
<ClInclude Include="include\Poco\Net\SSLException.h"/>
<ClInclude Include="include\Poco\Net\SSLManager.h"/>
<ClInclude Include="include\Poco\Net\Utility.h"/>
<ClInclude Include="include\Poco\Net\VerificationErrorArgs.h"/>
<ClInclude Include="include\Poco\Net\X509Certificate.h"/>
<ClInclude Include="include\Poco\Net\HTTPSClientSession.h"/>
<ClInclude Include="include\Poco\Net\HTTPSSessionInstantiator.h"/>
<ClInclude Include="include\Poco\Net\HTTPSStreamFactory.h"/>
<ClInclude Include="include\Poco\Net\SecureServerSocket.h"/>
<ClInclude Include="include\Poco\Net\SecureServerSocketImpl.h"/>
<ClInclude Include="include\Poco\Net\SecureSocketImpl.h"/>
<ClInclude Include="include\Poco\Net\SecureStreamSocket.h"/>
<ClInclude Include="include\Poco\Net\SecureStreamSocketImpl.h"/>
<ClInclude Include="include\Poco\Net\SecureSMTPClientSession.h"/>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\AcceptCertificateHandler.cpp"/>
<ClCompile Include="src\CertificateHandlerFactory.cpp"/>
<ClCompile Include="src\CertificateHandlerFactoryMgr.cpp"/>
<ClCompile Include="src\ConsoleCertificateHandler.cpp"/>
<ClCompile Include="src\Context.cpp"/>
<ClCompile Include="src\InvalidCertificateHandler.cpp"/>
<ClCompile Include="src\KeyConsoleHandler.cpp"/>
<ClCompile Include="src\KeyFileHandler.cpp"/>
<ClCompile Include="src\PrivateKeyFactory.cpp"/>
<ClCompile Include="src\PrivateKeyFactoryMgr.cpp"/>
<ClCompile Include="src\PrivateKeyPassphraseHandler.cpp"/>
<ClCompile Include="src\RejectCertificateHandler.cpp"/>
<ClCompile Include="src\Session.cpp"/>
<ClCompile Include="src\SSLException.cpp"/>
<ClCompile Include="src\SSLManager.cpp"/>
<ClCompile Include="src\Utility.cpp"/>
<ClCompile Include="src\VerificationErrorArgs.cpp"/>
<ClCompile Include="src\X509Certificate.cpp"/>
<ClCompile Include="src\HTTPSClientSession.cpp"/>
<ClCompile Include="src\HTTPSSessionInstantiator.cpp"/>
<ClCompile Include="src\HTTPSStreamFactory.cpp"/>
<ClCompile Include="src\SecureServerSocket.cpp"/>
<ClCompile Include="src\SecureServerSocketImpl.cpp"/>
<ClCompile Include="src\SecureSocketImpl.cpp"/>
<ClCompile Include="src\SecureStreamSocket.cpp"/>
<ClCompile Include="src\SecureStreamSocketImpl.cpp"/>
<ClCompile Include="src\SecureSMTPClientSession.cpp"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"/>
</Project>

View File

@@ -0,0 +1,210 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="SSLCore">
<UniqueIdentifier>{d9eaf0d6-f474-4ee8-aca5-32b62781b273}</UniqueIdentifier>
</Filter>
<Filter Include="SSLCore\Header Files">
<UniqueIdentifier>{2998d636-8208-443f-be6d-13715d6203eb}</UniqueIdentifier>
</Filter>
<Filter Include="SSLCore\Source Files">
<UniqueIdentifier>{1934c0e0-1d82-426d-a11e-581ea7ce5530}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient">
<UniqueIdentifier>{affd39f4-c370-4ba3-b1f1-9b7881bbe432}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient\Header Files">
<UniqueIdentifier>{7e2fce43-24c5-4d04-a1ec-a572a20702fe}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient\Source Files">
<UniqueIdentifier>{70a55b6d-855e-4e34-931f-2b3d2a5a66bf}</UniqueIdentifier>
</Filter>
<Filter Include="SSLSockets">
<UniqueIdentifier>{4d42ad9b-28fa-46d0-bba8-9c61d26a2715}</UniqueIdentifier>
</Filter>
<Filter Include="SSLSockets\Header Files">
<UniqueIdentifier>{548fa4c8-2205-48cb-ac60-ab525fadcd72}</UniqueIdentifier>
</Filter>
<Filter Include="SSLSockets\Source Files">
<UniqueIdentifier>{fb31cd98-5924-4db5-889a-49a91b53c5e0}</UniqueIdentifier>
</Filter>
<Filter Include="Mail">
<UniqueIdentifier>{3dbb15f4-2822-47e4-8a2b-0da5c4b567a5}</UniqueIdentifier>
</Filter>
<Filter Include="Mail\Header Files">
<UniqueIdentifier>{235da22e-e34e-4ac2-a809-0b8789ead1c4}</UniqueIdentifier>
</Filter>
<Filter Include="Mail\Source Files">
<UniqueIdentifier>{eee01a7c-24b9-42a3-9151-b6e909f68c00}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\Poco\Net\AcceptCertificateHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\CertificateHandlerFactory.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\CertificateHandlerFactoryMgr.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\ConsoleCertificateHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\Context.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\InvalidCertificateHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\KeyConsoleHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\KeyFileHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\NetSSL.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\PrivateKeyFactory.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\PrivateKeyFactoryMgr.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\PrivateKeyPassphraseHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\RejectCertificateHandler.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\Session.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SSLException.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SSLManager.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\Utility.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\VerificationErrorArgs.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\X509Certificate.h">
<Filter>SSLCore\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\HTTPSClientSession.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\HTTPSSessionInstantiator.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\HTTPSStreamFactory.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureServerSocket.h">
<Filter>SSLSockets\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureServerSocketImpl.h">
<Filter>SSLSockets\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureSocketImpl.h">
<Filter>SSLSockets\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureStreamSocket.h">
<Filter>SSLSockets\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureStreamSocketImpl.h">
<Filter>SSLSockets\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\Net\SecureSMTPClientSession.h">
<Filter>Mail\Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\AcceptCertificateHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\CertificateHandlerFactory.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\CertificateHandlerFactoryMgr.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\ConsoleCertificateHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Context.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\InvalidCertificateHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\KeyConsoleHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\KeyFileHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\PrivateKeyFactory.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\PrivateKeyFactoryMgr.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\PrivateKeyPassphraseHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\RejectCertificateHandler.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Session.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SSLException.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SSLManager.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Utility.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\VerificationErrorArgs.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\X509Certificate.cpp">
<Filter>SSLCore\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSClientSession.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSSessionInstantiator.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSStreamFactory.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureServerSocket.cpp">
<Filter>SSLSockets\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureServerSocketImpl.cpp">
<Filter>SSLSockets\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureSocketImpl.cpp">
<Filter>SSLSockets\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureStreamSocket.cpp">
<Filter>SSLSockets\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureStreamSocketImpl.cpp">
<Filter>SSLSockets\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SecureSMTPClientSession.cpp">
<Filter>Mail\Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -1,175 +1,317 @@
// //
// Context.h // Context.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/Context.h#9 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/Context.h#9 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: Context // Module: Context
// //
// Definition of the Context class. // Definition of the Context class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_Context_INCLUDED #ifndef NetSSL_Context_INCLUDED
#define NetSSL_Context_INCLUDED #define NetSSL_Context_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/RefCountedObject.h" #include "Poco/Net/SocketDefs.h"
#include "Poco/AutoPtr.h" #include "Poco/Crypto/X509Certificate.h"
#include <openssl/ssl.h> #include "Poco/Crypto/RSAKey.h"
#include "Poco/RefCountedObject.h"
#include "Poco/AutoPtr.h"
namespace Poco { #include <openssl/ssl.h>
namespace Net { #include <cstdlib>
class NetSSL_API Context: public Poco::RefCountedObject namespace Poco {
/// This class encapsulates context information for namespace Net {
/// an SSL server or client, such as the certificate
/// verification mode and the location of certificates
/// and private key files, as well as the list of class NetSSL_API Context: public Poco::RefCountedObject
/// supported ciphers. /// This class encapsulates context information for
{ /// an SSL server or client, such as the certificate
public: /// verification mode and the location of certificates
typedef Poco::AutoPtr<Context> Ptr; /// and private key files, as well as the list of
/// supported ciphers.
enum Usage ///
{ /// The Context class is also used to control
CLIENT_USE, /// Context is used by a client. /// SSL session caching on the server and client side.
SERVER_USE /// Context is used by a server. {
}; public:
typedef Poco::AutoPtr<Context> Ptr;
enum VerificationMode
{ enum Usage
VERIFY_NONE = SSL_VERIFY_NONE, {
/// Server: The server will not send a client certificate CLIENT_USE, /// Context is used by a client.
/// request to the client, so the client will not send a certificate. SERVER_USE /// Context is used by a server.
/// };
/// Client: If not using an anonymous cipher (by default disabled),
/// the server will send a certificate which will be checked, but enum VerificationMode
/// the result of the check will be ignored. {
VERIFY_NONE = SSL_VERIFY_NONE,
VERIFY_RELAXED = SSL_VERIFY_PEER, /// Server: The server will not send a client certificate
/// Server: The server sends a client certificate request to the /// request to the client, so the client will not send a certificate.
/// client. The certificate returned (if any) is checked. ///
/// If the verification process fails, the TLS/SSL handshake is /// Client: If not using an anonymous cipher (by default disabled),
/// immediately terminated with an alert message containing the /// the server will send a certificate which will be checked, but
/// reason for the verification failure. /// the result of the check will be ignored.
///
/// Client: The server certificate is verified, if one is provided. VERIFY_RELAXED = SSL_VERIFY_PEER,
/// If the verification process fails, the TLS/SSL handshake is /// Server: The server sends a client certificate request to the
/// immediately terminated with an alert message containing the /// client. The certificate returned (if any) is checked.
/// reason for the verification failure. /// If the verification process fails, the TLS/SSL handshake is
/// immediately terminated with an alert message containing the
VERIFY_STRICT = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, /// reason for the verification failure.
/// Server: If the client did not return a certificate, the TLS/SSL ///
/// handshake is immediately terminated with a handshake failure /// Client: The server certificate is verified, if one is provided.
/// alert. This flag must be used together with SSL_VERIFY_PEER. /// If the verification process fails, the TLS/SSL handshake is
/// /// immediately terminated with an alert message containing the
/// Client: Same as VERIFY_RELAXED. /// reason for the verification failure.
VERIFY_ONCE = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE VERIFY_STRICT = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
/// Server: Only request a client certificate on the initial /// Server: If the client did not return a certificate, the TLS/SSL
/// TLS/SSL handshake. Do not ask for a client certificate /// handshake is immediately terminated with a handshake failure
/// again in case of a renegotiation. /// alert. This flag must be used together with SSL_VERIFY_PEER.
/// ///
/// Client: Same as VERIFY_RELAXED. /// Client: Same as VERIFY_RELAXED.
};
VERIFY_ONCE = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE
Context( /// Server: Only request a client certificate on the initial
Usage usage, /// TLS/SSL handshake. Do not ask for a client certificate
const std::string& privateKeyFile, /// again in case of a renegotiation.
const std::string& certificateFile, ///
const std::string& caLocation, /// Client: Same as VERIFY_RELAXED.
VerificationMode verificationMode = VERIFY_RELAXED, };
int verificationDepth = 9,
bool loadDefaultCAs = false, Context(
const std::string& cipherList = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); Usage usage,
/// Creates a Context. const std::string& privateKeyFile,
/// const std::string& certificateFile,
/// * usage specifies whether the context is used by a client or server. const std::string& caLocation,
/// * privateKeyFile contains the path to the private key file used for encryption. VerificationMode verificationMode = VERIFY_RELAXED,
/// Can be empty if no private key file is used. int verificationDepth = 9,
/// * certificateFile contains the path to the certificate file (in PEM format). bool loadDefaultCAs = false,
/// If the private key and the certificate are stored in the same file, this const std::string& cipherList = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
/// can be empty if privateKeyFile is given. /// Creates a Context.
/// * caLocation contains the path to the file or directory containing the ///
/// CA/root certificates. Can be empty if the OpenSSL builtin CA certificates /// * usage specifies whether the context is used by a client or server.
/// are used (see loadDefaultCAs). /// * privateKeyFile contains the path to the private key file used for encryption.
/// * verificationMode specifies whether and how peer certificates are validated. /// Can be empty if no private key file is used.
/// * verificationDepth sets the upper limit for verification chain sizes. Verification /// * certificateFile contains the path to the certificate file (in PEM format).
/// will fail if a certificate chain larger than this is encountered. /// If the private key and the certificate are stored in the same file, this
/// * loadDefaultCAs specifies wheter the builtin CA certificates from OpenSSL are used. /// can be empty if privateKeyFile is given.
/// * cipherList specifies the supported ciphers in OpenSSL notation. /// * caLocation contains the path to the file or directory containing the
/// CA/root certificates. Can be empty if the OpenSSL builtin CA certificates
~Context(); /// are used (see loadDefaultCAs).
/// Destroys the Context. /// * verificationMode specifies whether and how peer certificates are validated.
/// * verificationDepth sets the upper limit for verification chain sizes. Verification
SSL_CTX* sslContext() const; /// will fail if a certificate chain larger than this is encountered.
/// Returns the underlying OpenSSL SSL Context object. /// * loadDefaultCAs specifies wheter the builtin CA certificates from OpenSSL are used.
/// * cipherList specifies the supported ciphers in OpenSSL notation.
Usage usage() const; ///
/// Returns whether the context is for use by a client or by a server. /// Note: If the private key is protected by a passphrase, a PrivateKeyPassphraseHandler
/// must have been setup with the SSLManager, or the SSLManager's PrivateKeyPassphraseRequired
Context::VerificationMode verificationMode() const; /// event must be handled.
/// Returns the verification mode.
Context(
private: Usage usage,
Usage _usage; const std::string& caLocation,
VerificationMode _mode; VerificationMode verificationMode = VERIFY_RELAXED,
SSL_CTX* _pSSLContext; int verificationDepth = 9,
}; bool loadDefaultCAs = false,
const std::string& cipherList = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
/// Creates a Context.
// ///
// inlines /// * usage specifies whether the context is used by a client or server.
// /// * caLocation contains the path to the file or directory containing the
inline Context::Usage Context::usage() const /// CA/root certificates. Can be empty if the OpenSSL builtin CA certificates
{ /// are used (see loadDefaultCAs).
return _usage; /// * verificationMode specifies whether and how peer certificates are validated.
} /// * verificationDepth sets the upper limit for verification chain sizes. Verification
/// will fail if a certificate chain larger than this is encountered.
/// * loadDefaultCAs specifies wheter the builtin CA certificates from OpenSSL are used.
inline Context::VerificationMode Context::verificationMode() const /// * cipherList specifies the supported ciphers in OpenSSL notation.
{ ///
return _mode; /// Note that a private key and/or certificate must be specified with
} /// usePrivateKey()/useCertificate() before the Context can be used.
~Context();
inline SSL_CTX* Context::sslContext() const /// Destroys the Context.
{
return _pSSLContext; void useCertificate(const Poco::Crypto::X509Certificate& certificate);
} /// Sets the certificate to be used by the Context.
///
/// To set-up a complete certificate chain, it might be
} } // namespace Poco::Net /// necessary to call addChainCertificate() to specify
/// additional certificates.
///
#endif // NetSSL_Context_INCLUDED /// Note that useCertificate() must always be called before
/// usePrivateKey().
void addChainCertificate(const Poco::Crypto::X509Certificate& certificate);
/// Adds a certificate for certificate chain validation.
void usePrivateKey(const Poco::Crypto::RSAKey& key);
/// Sets the private key to be used by the Context.
///
/// Note that useCertificate() must always be called before
/// usePrivateKey().
///
/// Note: If the private key is protected by a passphrase, a PrivateKeyPassphraseHandler
/// must have been setup with the SSLManager, or the SSLManager's PrivateKeyPassphraseRequired
/// event must be handled.
SSL_CTX* sslContext() const;
/// Returns the underlying OpenSSL SSL Context object.
Usage usage() const;
/// Returns whether the context is for use by a client or by a server.
Context::VerificationMode verificationMode() const;
/// Returns the verification mode.
void enableSessionCache(bool flag = true);
/// Enable or disable SSL/TLS session caching.
/// For session caching to work, it must be enabled
/// on the server, as well as on the client side.
///
/// The default is disabled session caching.
///
/// To enable session caching on the server side, use the
/// two-argument version of this method to specify
/// a session ID context.
void enableSessionCache(bool flag, const std::string& sessionIdContext);
/// Enables or disables SSL/TLS session caching on the server.
/// For session caching to work, it must be enabled
/// on the server, as well as on the client side.
///
/// SessionIdContext contains the application's unique
/// session ID context, which becomes part of each
/// session identifier generated by the server within this
/// context. SessionIdContext can be an arbitrary sequence
/// of bytes with a maximum length of SSL_MAX_SSL_SESSION_ID_LENGTH.
///
/// A non-empty sessionIdContext should be specified even if
/// session caching is disabled to avoid problems with clients
/// requesting to reuse a session (e.g. Firefox 3.6).
///
/// This method may only be called on SERVER_USE Context objects.
bool sessionCacheEnabled() const;
/// Returns true iff the session cache is enabled.
void setSessionCacheSize(std::size_t size);
/// Sets the maximum size of the server session cache, in number of
/// sessions. The default size (according to OpenSSL documentation)
/// is 1024*20, which may be too large for many applications,
/// especially on embedded platforms with limited memory.
///
/// Specifying a size of 0 will set an unlimited cache size.
///
/// This method may only be called on SERVER_USE Context objets.
std::size_t getSessionCacheSize() const;
/// Returns the current maximum size of the server session cache.
///
/// This method may only be called on SERVER_USE Context objets.
void setSessionTimeout(long seconds);
/// Sets the timeout (in seconds) of cached sessions on the server.
/// A cached session will be removed from the cache if it has
/// not been used for the given number of seconds.
///
/// This method may only be called on SERVER_USE Context objets.
long getSessionTimeout() const;
/// Returns the timeout (in seconds) of cached sessions on the server.
///
/// This method may only be called on SERVER_USE Context objets.
void flushSessionCache();
/// Flushes the SSL session cache on the server.
///
/// This method may only be called on SERVER_USE Context objets.
void enableExtendedCertificateVerification(bool flag = true);
/// Enable or disable the automatic post-connection
/// extended certificate verification.
///
/// See X509Certificate::verify() for more information.
bool extendedCertificateVerificationEnabled() const;
/// Returns true iff automatic extended certificate
/// verification is enabled.
void disableStatelessSessionResumption();
/// Newer versions of OpenSSL support RFC 4507 tickets for stateless
/// session resumption.
///
/// The feature can be disabled by calling this method.
private:
Usage _usage;
VerificationMode _mode;
SSL_CTX* _pSSLContext;
bool _extendedCertificateVerification;
};
//
// inlines
//
inline Context::Usage Context::usage() const
{
return _usage;
}
inline Context::VerificationMode Context::verificationMode() const
{
return _mode;
}
inline SSL_CTX* Context::sslContext() const
{
return _pSSLContext;
}
inline bool Context::extendedCertificateVerificationEnabled() const
{
return _extendedCertificateVerification;
}
} } // namespace Poco::Net
#endif // NetSSL_Context_INCLUDED

View File

@@ -1,137 +1,186 @@
// //
// HTTPSClientSession.h // HTTPSClientSession.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/HTTPSClientSession.h#9 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/HTTPSClientSession.h#9 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: HTTPSClient // Package: HTTPSClient
// Module: HTTPSClientSession // Module: HTTPSClientSession
// //
// Definition of the HTTPSClientSession class. // Definition of the HTTPSClientSession class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_HTTPSClientSession_INCLUDED #ifndef NetSSL_HTTPSClientSession_INCLUDED
#define NetSSL_HTTPSClientSession_INCLUDED #define NetSSL_HTTPSClientSession_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/Net/Utility.h" #include "Poco/Net/Utility.h"
#include "Poco/Net/HTTPClientSession.h" #include "Poco/Net/HTTPClientSession.h"
#include "Poco/Net/Context.h" #include "Poco/Net/Context.h"
#include "Poco/Net/X509Certificate.h" #include "Poco/Net/Session.h"
#include "Poco/Net/X509Certificate.h"
namespace Poco {
namespace Net { namespace Poco {
namespace Net {
class SecureStreamSocket;
class HTTPRequest; class SecureStreamSocket;
class HTTPResponse; class HTTPRequest;
class HTTPResponse;
class NetSSL_API HTTPSClientSession: public HTTPClientSession
/// This class implements the client-side of class NetSSL_API HTTPSClientSession: public HTTPClientSession
/// a HTTPS session. /// This class implements the client-side of
/// /// a HTTPS session.
/// To send a HTTPS request to a HTTPS server, first ///
/// instantiate a HTTPSClientSession object and /// To send a HTTPS request to a HTTPS server, first
/// specify the server's host name and port number. /// instantiate a HTTPSClientSession object and
/// /// specify the server's host name and port number.
/// Then create a HTTPRequest object, fill it accordingly, ///
/// and pass it as argument to the sendRequst() method. /// Then create a HTTPRequest object, fill it accordingly,
/// /// and pass it as argument to the sendRequst() method.
/// sendRequest() will return an output stream that can ///
/// be used to send the request body, if there is any. /// sendRequest() will return an output stream that can
/// /// be used to send the request body, if there is any.
/// After you are done sending the request body, create ///
/// a HTTPResponse object and pass it to receiveResponse(). /// After you are done sending the request body, create
/// /// a HTTPResponse object and pass it to receiveResponse().
/// This will return an input stream that can be used to ///
/// read the response body. /// This will return an input stream that can be used to
/// /// read the response body.
/// See RFC 2616 <http://www.faqs.org/rfcs/rfc2616.html> for more ///
/// information about the HTTP protocol. /// See RFC 2616 <http://www.faqs.org/rfcs/rfc2616.html> for more
/// /// information about the HTTP protocol.
/// Note that sending requests that neither contain a content length ///
/// field in the header nor are using chunked transfer encoding will /// Note that sending requests that neither contain a content length
/// result in a SSL protocol violation, as the framework shuts down /// field in the header nor are using chunked transfer encoding will
/// the socket after sending the message body. No orderly SSL shutdown /// result in a SSL protocol violation, as the framework shuts down
/// will be performed in this case. /// the socket after sending the message body. No orderly SSL shutdown
{ /// will be performed in this case.
public: ///
enum /// If session caching has been enabled for the Context object passed
{ /// to the HTTPSClientSession, the HTTPSClientSession class will
HTTPS_PORT = 443 /// attempt to reuse a previously obtained Session object in
}; /// case of a reconnect.
{
HTTPSClientSession(); public:
/// Creates an unconnected HTTPSClientSession. enum
{
explicit HTTPSClientSession(const SecureStreamSocket& socket); HTTPS_PORT = 443
/// Creates a HTTPSClientSession using the given socket. };
/// The socket must not be connected. The session
/// takes ownership of the socket. HTTPSClientSession();
/// Creates an unconnected HTTPSClientSession.
HTTPSClientSession(const std::string& host, Poco::UInt16 port = HTTPS_PORT);
/// Creates a HTTPSClientSession using the given host and port. explicit HTTPSClientSession(const SecureStreamSocket& socket);
/// Creates a HTTPSClientSession using the given socket.
explicit HTTPSClientSession(Context::Ptr pContext); /// The socket must not be connected. The session
/// Creates an unconnected HTTPSClientSession, using the /// takes ownership of the socket.
/// give SSL context.
HTTPSClientSession(const SecureStreamSocket& socket, Session::Ptr pSession);
HTTPSClientSession(const std::string& host, Poco::UInt16 port, Context::Ptr pContext); /// Creates a HTTPSClientSession using the given socket.
/// Creates a HTTPSClientSession using the given host and port, /// The socket must not be connected. The session
/// using the given SSL context. /// takes ownership of the socket.
///
~HTTPSClientSession(); /// The given Session is reused, if possible (client session
/// Destroys the HTTPSClientSession and closes /// caching is enabled for the given Context, and the server
/// the underlying socket. /// agrees to reuse the session).
X509Certificate serverCertificate(); HTTPSClientSession(const std::string& host, Poco::UInt16 port = HTTPS_PORT);
/// Returns the server's certificate. /// Creates a HTTPSClientSession using the given host and port.
///
/// The certificate is available after the first request has been sent. explicit HTTPSClientSession(Context::Ptr pContext);
/// Creates an unconnected HTTPSClientSession, using the
protected: /// give SSL context.
void connect(const SocketAddress& address);
std::string proxyRequestPrefix() const; HTTPSClientSession(Context::Ptr pContext, Session::Ptr pSession);
/// Creates an unconnected HTTPSClientSession, using the
private: /// give SSL context.
HTTPSClientSession(const HTTPSClientSession&); ///
HTTPSClientSession& operator = (const HTTPSClientSession&); /// The given Session is reused, if possible (client session
/// caching is enabled for the given Context, and the server
Context::Ptr _pContext; /// agrees to reuse the session).
};
HTTPSClientSession(const std::string& host, Poco::UInt16 port, Context::Ptr pContext);
/// Creates a HTTPSClientSession using the given host and port,
} } // namespace Poco::Net /// using the given SSL context.
HTTPSClientSession(const std::string& host, Poco::UInt16 port, Context::Ptr pContext, Session::Ptr pSession);
#endif // Net_HTTPSClientSession_INCLUDED /// Creates a HTTPSClientSession using the given host and port,
/// using the given SSL context.
///
/// The given Session is reused, if possible (client session
/// caching is enabled for the given Context, and the server
/// agrees to reuse the session).
~HTTPSClientSession();
/// Destroys the HTTPSClientSession and closes
/// the underlying socket.
bool secure() const;
/// Return true iff the session uses SSL or TLS,
/// or false otherwise.
X509Certificate serverCertificate();
/// Returns the server's certificate.
///
/// The certificate is available after the first request has been sent.
Session::Ptr sslSession();
/// Returns the SSL Session object for the current
/// connection, if session caching has been enabled for
/// the HTTPSClientSession's Context. A null pointer is
/// returned otherwise.
///
/// The Session object can be obtained after the first request has
/// been sent.
// HTTPSession
void abort();
protected:
void connect(const SocketAddress& address);
std::string proxyRequestPrefix() const;
void proxyAuthenticate(HTTPRequest& request);
private:
HTTPSClientSession(const HTTPSClientSession&);
HTTPSClientSession& operator = (const HTTPSClientSession&);
Context::Ptr _pContext;
Session::Ptr _pSession;
};
} } // namespace Poco::Net
#endif // Net_HTTPSClientSession_INCLUDED

View File

@@ -1,92 +1,101 @@
// //
// HTTPSStreamFactory.h // HTTPSStreamFactory.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/HTTPSStreamFactory.h#7 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/HTTPSStreamFactory.h#7 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: HTTPSClient // Package: HTTPSClient
// Module: HTTPSStreamFactory // Module: HTTPSStreamFactory
// //
// Definition of the HTTPSStreamFactory class. // Definition of the HTTPSStreamFactory class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_HTTPSStreamFactory_INCLUDED #ifndef NetSSL_HTTPSStreamFactory_INCLUDED
#define NetSSL_HTTPSStreamFactory_INCLUDED #define NetSSL_HTTPSStreamFactory_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/Net/HTTPSession.h" #include "Poco/Net/HTTPSession.h"
#include "Poco/URIStreamFactory.h" #include "Poco/URIStreamFactory.h"
namespace Poco { namespace Poco {
namespace Net { namespace Net {
class NetSSL_API HTTPSStreamFactory: public Poco::URIStreamFactory class NetSSL_API HTTPSStreamFactory: public Poco::URIStreamFactory
/// An implementation of the URIStreamFactory interface /// An implementation of the URIStreamFactory interface
/// that handles secure Hyper-Text Transfer Protocol (https) URIs. /// that handles secure Hyper-Text Transfer Protocol (https) URIs.
{ {
public: public:
HTTPSStreamFactory(); HTTPSStreamFactory();
/// Creates the HTTPSStreamFactory. /// Creates the HTTPSStreamFactory.
HTTPSStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort = HTTPSession::HTTP_PORT); HTTPSStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort = HTTPSession::HTTP_PORT);
/// Creates the HTTPSStreamFactory. /// Creates the HTTPSStreamFactory.
/// ///
/// HTTP connections will use the given proxy. /// HTTPS connections will use the given proxy.
~HTTPSStreamFactory(); HTTPSStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort, const std::string& proxyUsername, const std::string& proxyPassword);
/// Destroys the HTTPSStreamFactory. /// Creates the HTTPSStreamFactory.
///
std::istream* open(const Poco::URI& uri); /// HTTPS connections will use the given proxy and
/// Creates and opens a HTTPS stream for the given URI. /// will be authorized against the proxy using Basic authentication
/// The URI must be a https://... URI. /// with the given proxyUsername and proxyPassword.
///
/// Throws a NetException if anything goes wrong. ~HTTPSStreamFactory();
/// Destroys the HTTPSStreamFactory.
static void registerFactory();
/// Registers the HTTPSStreamFactory with the std::istream* open(const Poco::URI& uri);
/// default URIStreamOpener instance. /// Creates and opens a HTTPS stream for the given URI.
/// The URI must be a https://... URI.
private: ///
enum /// Throws a NetException if anything goes wrong.
{
MAX_REDIRECTS = 10 static void registerFactory();
}; /// Registers the HTTPSStreamFactory with the
/// default URIStreamOpener instance.
std::string _proxyHost;
Poco::UInt16 _proxyPort; private:
}; enum
{
MAX_REDIRECTS = 10
} } // namespace Poco::Net };
std::string _proxyHost;
#endif // Net_HTTPSStreamFactory_INCLUDED Poco::UInt16 _proxyPort;
std::string _proxyUsername;
std::string _proxyPassword;
};
} } // namespace Poco::Net
#endif // Net_HTTPSStreamFactory_INCLUDED

View File

@@ -1,92 +1,109 @@
// //
// NetSSL.h // NetSSL.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/NetSSL.h#8 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/NetSSL.h#8 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: OpenSSL // Module: OpenSSL
// //
// Basic definitions for the Poco OpenSSL library. // Basic definitions for the Poco OpenSSL library.
// This file must be the first file included by every other OpenSSL // This file must be the first file included by every other OpenSSL
// header file. // header file.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_NetSSL_INCLUDED #ifndef NetSSL_NetSSL_INCLUDED
#define NetSSL_NetSSL_INCLUDED #define NetSSL_NetSSL_INCLUDED
#include "Poco/Net/Net.h" #include "Poco/Net/Net.h"
// //
// The following block is the standard way of creating macros which make exporting // The following block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the NetSSL_EXPORTS // from a DLL simpler. All files within this DLL are compiled with the NetSSL_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project // symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see // that uses this DLL. This way any other project whose source files include this file see
// NetSSL_API functions as being imported from a DLL, wheras this DLL sees symbols // NetSSL_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported. // defined with this macro as being exported.
// //
#if (defined(_WIN32) || defined(__CYGWIN__)) && defined(POCO_DLL) #if (defined(_WIN32) || defined(__CYGWIN__)) && defined(POCO_DLL)
#if defined(NetSSL_EXPORTS) #if defined(NetSSL_EXPORTS)
#define NetSSL_API __declspec(dllexport) #define NetSSL_API __declspec(dllexport)
#else #else
#define NetSSL_API __declspec(dllimport) #define NetSSL_API __declspec(dllimport)
#endif #endif
#endif #endif
#if !defined(NetSSL_API) #if !defined(NetSSL_API)
#define NetSSL_API #define NetSSL_API
#endif #endif
// //
// Automatically link NetSSL library. // Automatically link NetSSL library.
// //
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(NetSSL_EXPORTS) #if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(NetSSL_EXPORTS)
#if defined(POCO_DLL) #pragma comment(lib, "PocoNetSSL" POCO_LIB_SUFFIX)
#if defined(_DEBUG) #endif
#pragma comment(lib, "PocoNetSSLd.lib") #endif
#else
#pragma comment(lib, "PocoNetSSL.lib")
#endif namespace Poco {
#else namespace Net {
#if defined(_DEBUG)
#pragma comment(lib, "PocoNetSSLmtd.lib")
#else void NetSSL_API initializeSSL();
#pragma comment(lib, "PocoNetSSLmt.lib") /// Initialize the NetSSL library, as well as the underlying OpenSSL
#endif /// libraries, by calling Poco::Crypto::OpenSSLInitializer::initialize().
#endif ///
#endif /// Should be called before using any class from the NetSSL library.
#endif /// The NetSSL will be initialized automatically, through
/// Poco::Crypto::OpenSSLInitializer instances or similar mechanisms
/// when creating Context or SSLManager instances.
#endif // NetSSL_NetSSL_INCLUDED /// However, it is recommended to call initializeSSL()
/// in any case at application startup.
///
/// Can be called multiple times; however, for every call to
/// initializeSSL(), a matching call to uninitializeSSL()
/// must be performed.
void NetSSL_API uninitializeSSL();
/// Uninitializes the NetSSL library by calling
/// Poco::Crypto::OpenSSLInitializer::uninitialize() and
/// shutting down the SSLManager.
} } // namespace Poco::Net
#endif // NetSSL_NetSSL_INCLUDED

View File

@@ -0,0 +1,70 @@
//
// RejectCertificateHandler.h
//
// $Id: //poco/1.4/NetSSL_OpenSSL/include/Poco/Net/RejectCertificateHandler.h#1 $
//
// Library: NetSSL_OpenSSL
// Package: SSLCore
// Module: RejectCertificateHandler
//
// Definition of the RejectCertificateHandler class.
//
// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef NetSSL_RejectCertificateHandler_INCLUDED
#define NetSSL_RejectCertificateHandler_INCLUDED
#include "Poco/Net/NetSSL.h"
#include "Poco/Net/InvalidCertificateHandler.h"
namespace Poco {
namespace Net {
class NetSSL_API RejectCertificateHandler: public InvalidCertificateHandler
/// A RejectCertificateHandler is invoked whenever an error
/// occurs verifying the certificate. It always rejects
/// the certificate.
{
public:
RejectCertificateHandler(bool handleErrorsOnServerSide);
/// Creates the RejectCertificateHandler
virtual ~RejectCertificateHandler();
/// Destroys the RejectCertificateHandler.
void onInvalidCertificate(const void* pSender, VerificationErrorArgs& errorCert);
};
} } // namespace Poco::Net
#endif // NetSSL_RejectCertificateHandler_INCLUDED

View File

@@ -1,60 +1,61 @@
// //
// SSLException.h // SSLException.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SSLException.h#7 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SSLException.h#7 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: SSLException // Module: SSLException
// //
// Definition of the SSLException class. // Definition of the SSLException class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_SSLException_INCLUDED #ifndef NetSSL_SSLException_INCLUDED
#define NetSSL_SSLException_INCLUDED #define NetSSL_SSLException_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/Net/NetException.h" #include "Poco/Net/NetException.h"
namespace Poco { namespace Poco {
namespace Net { namespace Net {
POCO_DECLARE_EXCEPTION(NetSSL_API, SSLException, NetException) POCO_DECLARE_EXCEPTION(NetSSL_API, SSLException, NetException)
POCO_DECLARE_EXCEPTION(NetSSL_API, SSLContextException, SSLException) POCO_DECLARE_EXCEPTION(NetSSL_API, SSLContextException, SSLException)
POCO_DECLARE_EXCEPTION(NetSSL_API, InvalidCertificateException, SSLException) POCO_DECLARE_EXCEPTION(NetSSL_API, InvalidCertificateException, SSLException)
POCO_DECLARE_EXCEPTION(NetSSL_API, CertificateValidationException, SSLException) POCO_DECLARE_EXCEPTION(NetSSL_API, CertificateValidationException, SSLException)
POCO_DECLARE_EXCEPTION(NetSSL_API, SSLConnectionUnexpectedlyClosedException, SSLException)
} } // namespace Poco::Net
} } // namespace Poco::Net
#endif // NetSSL_SSLException_INCLUDED
#endif // NetSSL_SSLException_INCLUDED

View File

@@ -1,281 +1,388 @@
// //
// SSLManager.h // SSLManager.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h#7 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h#7 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: SSLManager // Module: SSLManager
// //
// Definition of the SSLManager class. // Definition of the SSLManager class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_SSLManager_INCLUDED #ifndef NetSSL_SSLManager_INCLUDED
#define NetSSL_SSLManager_INCLUDED #define NetSSL_SSLManager_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/Net/VerificationErrorArgs.h" #include "Poco/Net/VerificationErrorArgs.h"
#include "Poco/Net/Context.h" #include "Poco/Net/Context.h"
#include "Poco/Net/PrivateKeyFactoryMgr.h" #include "Poco/Net/PrivateKeyFactoryMgr.h"
#include "Poco/Net/CertificateHandlerFactoryMgr.h" #include "Poco/Net/CertificateHandlerFactoryMgr.h"
#include "Poco/Net/InvalidCertificateHandler.h" #include "Poco/Net/InvalidCertificateHandler.h"
#include "Poco/BasicEvent.h" #include "Poco/Util/AbstractConfiguration.h"
#include "Poco/SharedPtr.h" #include "Poco/BasicEvent.h"
#include <openssl/ssl.h> #include "Poco/SharedPtr.h"
#include "Poco/Mutex.h"
#include <openssl/ssl.h>
namespace Poco { #ifdef OPENSSL_FIPS
namespace Net { #include <openssl/fips.h>
#endif
class Context;
namespace Poco {
namespace Net {
class NetSSL_API SSLManager
/// SSLManager is a singleton for holding the default server/client
/// Context and PrivateKeyPassphraseHandler. class Context;
///
/// Either initialize via Poco::Util::Application or via the
/// initialize methods of the singleton. Note that the latter initialization must happen very early class NetSSL_API SSLManager
/// during program startup before somebody calls defaultClientContext()/defaultServerContext() /// SSLManager is a singleton for holding the default server/client
/// or any of the passPhraseHandler methods (which tries to auto-initialize /// Context and handling callbacks for certificate verification errors
/// the context and passphrase handler based on an Poco::Util::Application configuration). /// and private key passphrases.
/// ///
/// An exemplary documentation which sets either the server or client defaultcontext and creates a PrivateKeyPassphraseHandler /// Proper initialization of SSLManager is critical.
/// that reads the password from the XML file looks like this: ///
/// /// SSLManager can be initialized manually, by calling initializeServer()
/// <AppConfig> /// and/or initializeClient(), or intialization can be automatic. In the latter
/// <openSSL> /// case, a Poco::Util::Application instance must be available and the required
/// <server|client> /// configuration properties must be set (see below).
/// <privateKeyFile>mycert.key</privateKeyFile> ///
/// <certificateFile>mycert.crt</certificateFile> /// Note that manual intialization must happen very early in the application,
/// <caConfig>rootcert.pem</caConfig> /// before defaultClientContext() or defaultServerContext() are called.
/// <verificationMode>relaxed</verificationMode> ///
/// <verificationDepth>9</verificationDepth> /// If defaultClientContext() and defaultServerContext() are never called
/// <loadDefaultCAFile>true</loadDefaultCAFile> /// in an application, initialization of SSLManager can be omitted.
/// <cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList> /// However, in this case, delegates for the ServerVerificationError,
/// <privateKeyPassphraseHandler> /// ClientVerificationError and PrivateKeyPassphraseRequired events
/// <name>KeyFileHandler</name> /// must be registered.
/// <options> ///
/// <password>test</password> /// An exemplary documentation which sets either the server or client default context and creates
/// </options> /// a PrivateKeyPassphraseHandler that reads the password from the XML file looks like this:
/// </privateKeyPassphraseHandler> ///
/// <invalidCertificateHandler> /// <AppConfig>
/// <name>ConsoleCertificateHandler</name> /// <openSSL>
/// <options> /// <server|client>
/// </options> /// <privateKeyFile>mycert.key</privateKeyFile>
/// </invalidCertificateHandler> /// <certificateFile>mycert.crt</certificateFile>
/// </server|client> /// <caConfig>rootcert.pem</caConfig>
/// </openSSL> /// <verificationMode>none|relaxed|strict|once</verificationMode>
/// </AppConfig> /// <verificationDepth>1..9</verificationDepth>
{ /// <loadDefaultCAFile>true|false</loadDefaultCAFile>
public: /// <cipherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cipherList>
typedef Poco::SharedPtr<PrivateKeyPassphraseHandler> PrivateKeyPassphraseHandlerPtr; /// <privateKeyPassphraseHandler>
typedef Poco::SharedPtr<InvalidCertificateHandler> InvalidCertificateHandlerPtr; /// <name>KeyFileHandler</name>
/// <options>
Poco::BasicEvent<VerificationErrorArgs> ServerVerificationError; /// <password>test</password>
/// Thrown whenever a certificate error is detected by the server during a handshake. /// </options>
/// </privateKeyPassphraseHandler>
Poco::BasicEvent<VerificationErrorArgs> ClientVerificationError; /// <invalidCertificateHandler>
/// Thrown whenever a certificate error is detected by the client during a handshake. /// <name>ConsoleCertificateHandler</name>
/// </invalidCertificateHandler>
Poco::BasicEvent<std::string> PrivateKeyPassPhrase; /// <cacheSessions>true|false</cacheSessions>
/// Thrown when a encrypted certificate is loaded. Not setting the password /// <sessionIdContext>someString</sessionIdContext> <!-- server only -->
/// in the event parameter will result in a failure to load the certificate. /// <sessionCacheSize>0..n</sessionCacheSize> <!-- server only -->
/// /// <sessionTimeout>0..n</sessionTimeout> <!-- server only -->
/// Per default the SSLManager checks the configuration.xml file (path openSSL.privateKeyPassphraseHandler.name) /// <extendedVerification>true|false</extendedVerification>
/// for which default delegate it should register. If nothing is configured, /// </server|client>
/// a KeyConsoleHandler is used. /// <fips>false</fips>
/// </openSSL>
static SSLManager& instance(); /// </AppConfig>
/// Returns the instance of the SSLManager singleton. ///
/// Following is a list of supported configuration properties. Property names must always
void initializeServer(PrivateKeyPassphraseHandlerPtr ptrPassPhraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext); /// be prefixed with openSSL.server or openSSL.client. Some properties are only supported
/// Initializes the server side of the SSLManager with a default passphrase handler, a default invalid certificate handler and a default context. If this method /// for servers.
/// is never called the SSLmanager will try to initialize its members from an application configuration. ///
/// /// - privateKeyFile (string): The path to the file containing the private key for the certificate
/// Note: ALWAYS create the handlers before you create the context! /// in PEM format (or containing both the private key and the certificate).
/// /// - certificateFile (string): The Path to the file containing the server's or client's certificate
/// Valid initialization code would be: /// in PEM format. Can be omitted if the the file given in privateKeyFile contains the certificate as well.
/// SharedPtr<PrivateKeyPassphraseHandler> ptrConsole = new KeyConsoleHandler(); /// - caConfig (string): The path to the file or directory containing the trusted root certificates.
/// SharedPtr<InvalidCertificateHandler> ptrCert = new ConsoleCertificateHandler(); /// - verificationMode (string): Specifies whether and how peer certificates are validated (see
/// Context::Ptr ptrContext = new Context("any.pem", "rootcert.pem", Context::Relaxed, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); /// the Context class for details). Valid values are none, relaxed, strict, once.
/// /// - verificationDepth (integer, 1-9): Sets the upper limit for verification chain sizes. Verification
/// This method can only be called if no defaultContext is set yet. /// will fail if a certificate chain larger than this is encountered.
/// - loadDefaultCAFile (boolean): Specifies wheter the builtin CA certificates from OpenSSL are used.
void initializeClient(PrivateKeyPassphraseHandlerPtr ptrPassPhraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext); /// - cipherList (string): Specifies the supported ciphers in OpenSSL notation
/// Initializes the client side of the SSLManager with a default passphrase handler, a default invalid certificate handler and a default context. If this method /// (e.g. "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH").
/// is never called the SSLmanager will try to initialize its members from an application configuration. /// - privateKeyPassphraseHandler.name (string): The name of the class (subclass of PrivateKeyPassphraseHandler)
/// /// used for obtaining the passphrase for accessing the private key.
/// Note: ALWAYS create the handlers before you create the context! /// - privateKeyPassphraseHandler.options.password (string): The password to be used by KeyFileHandler.
/// /// - invalidCertificateHandler.name: The name of the class (subclass of CertificateHandler)
/// Valid initialization code would be: /// used for confirming invalid certificates.
/// SharedPtr<PrivateKeyPassphraseHandler> ptrConsole = new KeyConsoleHandler(); /// - cacheSessions (boolean): Enables or disables session caching.
/// SharedPtr<InvalidCertificateHandler> ptrCert = new ConsoleCertificateHandler(); /// - sessionIdContext (string): contains the application's unique session ID context, which becomes
/// Context::Ptr ptrContext = new Context("any.pem", "rootcert.pem", Context::Relaxed, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); /// part of each session identifier generated by the server. Can be an arbitrary sequence
/// /// of bytes with a maximum length of SSL_MAX_SSL_SESSION_ID_LENGTH. Should be specified
/// This method can only be called if no defaultContext is set yet. /// for a server to enable session caching. Should be specified even if session caching
/// is disabled to avoid problems with clients that request session caching (e.g. Firefox 3.6).
Context::Ptr defaultServerContext(); /// If not specified, defaults to ${application.name}.
/// Returns the default context used by the server. The first call to this method initializes the defaultContext /// - sessionCacheSize (integer): Sets the maximum size of the server session cache, in number of
/// from an application configuration. /// sessions. The default size (according to OpenSSL documentation) is 1024*20, which may be too
/// large for many applications, especially on embedded platforms with limited memory.
Context::Ptr defaultClientContext(); /// Specifying a size of 0 will set an unlimited cache size.
/// Returns the default context used by the client. The first call to this method initializes the defaultContext /// - sessionTimeout (integer): Sets the timeout (in seconds) of cached sessions on the server.
/// from an application configuration. /// - extendedVerification (boolean): Enable or disable the automatic post-connection
/// extended certificate verification.
PrivateKeyPassphraseHandlerPtr serverPassPhraseHandler(); /// - fips: Enable or disable OpenSSL FIPS mode. Only supported if the OpenSSL version
/// Returns the configured passphrase handler of the server. If none is set, the method will create a default one /// that this library is built against supports FIPS mode.
/// from an application configuration {
public:
InvalidCertificateHandlerPtr serverCertificateHandler(); typedef Poco::SharedPtr<PrivateKeyPassphraseHandler> PrivateKeyPassphraseHandlerPtr;
/// Returns an initialized certificate handler (used by the server to verify client cert) which determines how invalid certificates are treated. typedef Poco::SharedPtr<InvalidCertificateHandler> InvalidCertificateHandlerPtr;
/// If none is set, it will try to auto-initialize one from an application configuration.
Poco::BasicEvent<VerificationErrorArgs> ServerVerificationError;
PrivateKeyPassphraseHandlerPtr clientPassPhraseHandler(); /// Fired whenever a certificate verification error is detected by the server during a handshake.
/// Returns the configured passphrase handler of the client. If none is set, the method will create a default one
/// from an application configuration Poco::BasicEvent<VerificationErrorArgs> ClientVerificationError;
/// Fired whenever a certificate verification error is detected by the client during a handshake.
InvalidCertificateHandlerPtr clientCertificateHandler();
/// Returns an initialized certificate handler (used by the client to verify server cert) which determines how invalid certificates are treated. Poco::BasicEvent<std::string> PrivateKeyPassphraseRequired;
/// If none is set, it will try to auto-initialize one from an application configuration. /// Fired when a encrypted certificate is loaded. Not setting the password
/// in the event parameter will result in a failure to load the certificate.
PrivateKeyFactoryMgr& privateKeyFactoryMgr(); ///
/// Returns the private key factory manager which stores the /// Per default the SSLManager checks the configuration.xml file (path openSSL.privateKeyPassphraseHandler.name)
/// factories for the different registered passphrase handlers for private keys. /// for which default delegate it should register. If nothing is configured,
/// a KeyConsoleHandler is used.
CertificateHandlerFactoryMgr& certificateHandlerFactoryMgr();
/// Returns the CertificateHandlerFactoryMgr which stores the static SSLManager& instance();
/// factories for the different registered certificate handlers. /// Returns the instance of the SSLManager singleton.
static const std::string CFG_SERVER_PREFIX; void initializeServer(PrivateKeyPassphraseHandlerPtr ptrPassPhraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext);
static const std::string CFG_CLIENT_PREFIX; /// Initializes the server side of the SSLManager with a default passphrase handler, a default invalid certificate handler and a default context. If this method
/// is never called the SSLmanager will try to initialize its members from an application configuration.
protected: ///
static int verifyClientCallback(int ok, X509_STORE_CTX* pStore); /// PtrPassphraseHandler and ptrCertificateHandler can be 0. However, in this case, event delegates
/// The return value of this method defines how errors in /// must be registered with the ServerVerificationError and PrivateKeyPassphraseRequired events.
/// verification are handled. Return 0 to terminate the handshake, ///
/// or 1 to continue despite the error. /// Note: Always create the handlers (or register the corresponding event delegates) before creating
/// the Context, as during creation of the Context the passphrase for the private key might be needed.
static int verifyServerCallback(int ok, X509_STORE_CTX* pStore); ///
/// The return value of this method defines how errors in /// Valid initialization code would be:
/// verification are handled. Return 0 to terminate the handshake, /// SharedPtr<PrivateKeyPassphraseHandler> pConsoleHandler = new KeyConsoleHandler;
/// or 1 to continue despite the error. /// SharedPtr<InvalidCertificateHandler> pInvalidCertHandler = new ConsoleCertificateHandler;
/// Context::Ptr pContext = new Context(Context::SERVER_USE, "any.pem", "any.pem", "rootcert.pem", Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
static int privateKeyPasswdCallback(char* pBuf, int size, int flag, void* userData); /// SSLManager::instance().initializeServer(pConsoleHandler, pInvalidCertHandler, pContext);
/// Method is invoked by OpenSSL to retrieve a passwd for an encrypted certificate.
/// The request is delegated to the PrivatekeyPassword event. This method returns the void initializeClient(PrivateKeyPassphraseHandlerPtr ptrPassphraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext);
/// length of the password. /// Initializes the client side of the SSLManager with a default passphrase handler, a default invalid certificate handler and a default context. If this method
/// is never called the SSLmanager will try to initialize its members from an application configuration.
private: ///
SSLManager(); /// PtrPassphraseHandler and ptrCertificateHandler can be 0. However, in this case, event delegates
/// Creates the SSLManager. /// must be registered with the ClientVerificationError and PrivateKeyPassphraseRequired events.
///
~SSLManager(); /// Note: Always create the handlers (or register the corresponding event delegates) before creating
/// Destroys the SSLManager. /// the Context, as during creation of the Context the passphrase for the private key might be needed.
///
void initDefaultContext(bool server); /// Valid initialization code would be:
/// Inits the default context, the first time it is accessed. /// SharedPtr<PrivateKeyPassphraseHandler> pConsoleHandler = new KeyConsoleHandler;
/// SharedPtr<InvalidCertificateHandler> pInvalidCertHandler = new ConsoleCertificateHandler;
void initEvents(bool server); /// Context::Ptr pContext = new Context(Context::CLIENT_USE, "", "", "rootcert.pem", Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
/// Registers delegates at the events according to the configuration. /// SSLManager::instance().initializeClient(pConsoleHandler, pInvalidCertHandler, pContext);
void initPassPhraseHandler(bool server); Context::Ptr defaultServerContext();
/// Inits the passphrase handler. /// Returns the default Context used by the server.
///
void initCertificateHandler(bool server); /// Unless initializeServer() has been called, the first call to this method initializes the default Context
/// Inits the certificate handler. /// from the application configuration.
static int verifyCallback(bool server, int ok, X509_STORE_CTX* pStore); Context::Ptr defaultClientContext();
/// The return value of this method defines how errors in /// Returns the default Context used by the client.
/// verification are handled. Return 0 to terminate the handshake, ///
/// or 1 to continue despite the error. /// Unless initializeClient() has been called, the first call to this method initializes the default Context
/// from the application configuration.
PrivateKeyFactoryMgr _factoryMgr;
CertificateHandlerFactoryMgr _certHandlerFactoryMgr; PrivateKeyPassphraseHandlerPtr serverPassphraseHandler();
Context::Ptr _ptrDefaultServerContext; /// Returns the configured passphrase handler of the server. If none is set, the method will create a default one
PrivateKeyPassphraseHandlerPtr _ptrServerPassPhraseHandler; /// from an application configuration.
InvalidCertificateHandlerPtr _ptrServerCertificateHandler;
Context::Ptr _ptrDefaultClientContext; InvalidCertificateHandlerPtr serverCertificateHandler();
PrivateKeyPassphraseHandlerPtr _ptrClientPassPhraseHandler; /// Returns an initialized certificate handler (used by the server to verify client cert) which determines how invalid certificates are treated.
InvalidCertificateHandlerPtr _ptrClientCertificateHandler; /// If none is set, it will try to auto-initialize one from an application configuration.
static const std::string CFG_PRIV_KEY_FILE; PrivateKeyPassphraseHandlerPtr clientPassphraseHandler();
static const std::string CFG_CERTIFICATE_FILE; /// Returns the configured passphrase handler of the client. If none is set, the method will create a default one
static const std::string CFG_CA_LOCATION; /// from an application configuration.
static const std::string CFG_VER_MODE;
static const Context::VerificationMode VAL_VER_MODE; InvalidCertificateHandlerPtr clientCertificateHandler();
static const std::string CFG_VER_DEPTH; /// Returns an initialized certificate handler (used by the client to verify server cert) which determines how invalid certificates are treated.
static const int VAL_VER_DEPTH; /// If none is set, it will try to auto-initialize one from an application configuration.
static const std::string CFG_ENABLE_DEFAULT_CA;
static const bool VAL_ENABLE_DEFAULT_CA; PrivateKeyFactoryMgr& privateKeyFactoryMgr();
static const std::string CFG_CYPHER_LIST; /// Returns the private key factory manager which stores the
static const std::string VAL_CYPHER_LIST; /// factories for the different registered passphrase handlers for private keys.
static const std::string CFG_DELEGATE_HANDLER;
static const std::string VAL_DELEGATE_HANDLER; CertificateHandlerFactoryMgr& certificateHandlerFactoryMgr();
static const std::string CFG_CERTIFICATE_HANDLER; /// Returns the CertificateHandlerFactoryMgr which stores the
static const std::string VAL_CERTIFICATE_HANDLER; /// factories for the different registered certificate handlers.
friend class Poco::SingletonHolder<SSLManager>; static bool isFIPSEnabled();
friend class Context; // Returns true if FIPS mode is enabled, false otherwise.
};
void shutdown();
/// Shuts down the SSLManager and releases the default Context
// /// objects. After a call to shutdown(), the SSLManager can no
// inlines /// longer be used.
// ///
inline PrivateKeyFactoryMgr& SSLManager::privateKeyFactoryMgr() /// Normally, it's not necessary to call this method directly, as this
{ /// will be called either by uninitializeSSL(), or when
return _factoryMgr; /// the SSLManager instance is destroyed.
}
static const std::string CFG_SERVER_PREFIX;
static const std::string CFG_CLIENT_PREFIX;
inline CertificateHandlerFactoryMgr& SSLManager::certificateHandlerFactoryMgr()
{ protected:
return _certHandlerFactoryMgr; static int verifyClientCallback(int ok, X509_STORE_CTX* pStore);
} /// The return value of this method defines how errors in
/// verification are handled. Return 0 to terminate the handshake,
/// or 1 to continue despite the error.
inline int SSLManager::verifyServerCallback(int ok, X509_STORE_CTX* pStore)
{ static int verifyServerCallback(int ok, X509_STORE_CTX* pStore);
return SSLManager::verifyCallback(true, ok, pStore); /// The return value of this method defines how errors in
} /// verification are handled. Return 0 to terminate the handshake,
/// or 1 to continue despite the error.
inline int SSLManager::verifyClientCallback(int ok, X509_STORE_CTX* pStore) static int privateKeyPassphraseCallback(char* pBuf, int size, int flag, void* userData);
{ /// Method is invoked by OpenSSL to retrieve a passwd for an encrypted certificate.
return SSLManager::verifyCallback(false, ok, pStore); /// The request is delegated to the PrivatekeyPassword event. This method returns the
} /// length of the password.
static Poco::Util::AbstractConfiguration& appConfig();
} } // namespace Poco::Net /// Returns the application configuration.
///
/// Throws a
#endif // NetSSL_SSLManager_INCLUDED
private:
SSLManager();
/// Creates the SSLManager.
~SSLManager();
/// Destroys the SSLManager.
void initDefaultContext(bool server);
/// Inits the default context, the first time it is accessed.
void initEvents(bool server);
/// Registers delegates at the events according to the configuration.
void initPassphraseHandler(bool server);
/// Inits the passphrase handler.
void initCertificateHandler(bool server);
/// Inits the certificate handler.
static int verifyCallback(bool server, int ok, X509_STORE_CTX* pStore);
/// The return value of this method defines how errors in
/// verification are handled. Return 0 to terminate the handshake,
/// or 1 to continue despite the error.
PrivateKeyFactoryMgr _factoryMgr;
CertificateHandlerFactoryMgr _certHandlerFactoryMgr;
Context::Ptr _ptrDefaultServerContext;
PrivateKeyPassphraseHandlerPtr _ptrServerPassphraseHandler;
InvalidCertificateHandlerPtr _ptrServerCertificateHandler;
Context::Ptr _ptrDefaultClientContext;
PrivateKeyPassphraseHandlerPtr _ptrClientPassphraseHandler;
InvalidCertificateHandlerPtr _ptrClientCertificateHandler;
Poco::FastMutex _mutex;
static const std::string CFG_PRIV_KEY_FILE;
static const std::string CFG_CERTIFICATE_FILE;
static const std::string CFG_CA_LOCATION;
static const std::string CFG_VER_MODE;
static const Context::VerificationMode VAL_VER_MODE;
static const std::string CFG_VER_DEPTH;
static const int VAL_VER_DEPTH;
static const std::string CFG_ENABLE_DEFAULT_CA;
static const bool VAL_ENABLE_DEFAULT_CA;
static const std::string CFG_CIPHER_LIST;
static const std::string CFG_CYPHER_LIST; // for backwards compatibility
static const std::string VAL_CIPHER_LIST;
static const std::string CFG_DELEGATE_HANDLER;
static const std::string VAL_DELEGATE_HANDLER;
static const std::string CFG_CERTIFICATE_HANDLER;
static const std::string VAL_CERTIFICATE_HANDLER;
static const std::string CFG_CACHE_SESSIONS;
static const std::string CFG_SESSION_ID_CONTEXT;
static const std::string CFG_SESSION_CACHE_SIZE;
static const std::string CFG_SESSION_TIMEOUT;
static const std::string CFG_EXTENDED_VERIFICATION;
#ifdef OPENSSL_FIPS
static const std::string CFG_FIPS_MODE;
static const bool VAL_FIPS_MODE;
#endif
friend class Poco::SingletonHolder<SSLManager>;
friend class Context;
};
//
// inlines
//
inline PrivateKeyFactoryMgr& SSLManager::privateKeyFactoryMgr()
{
return _factoryMgr;
}
inline CertificateHandlerFactoryMgr& SSLManager::certificateHandlerFactoryMgr()
{
return _certHandlerFactoryMgr;
}
inline bool SSLManager::isFIPSEnabled()
{
#ifdef OPENSSL_FIPS
return FIPS_mode() ? true : false;
#else
return false;
#endif
}
inline int SSLManager::verifyServerCallback(int ok, X509_STORE_CTX* pStore)
{
return SSLManager::verifyCallback(true, ok, pStore);
}
inline int SSLManager::verifyClientCallback(int ok, X509_STORE_CTX* pStore)
{
return SSLManager::verifyCallback(false, ok, pStore);
}
} } // namespace Poco::Net
#endif // NetSSL_SSLManager_INCLUDED

View File

@@ -0,0 +1,115 @@
//
// SecureSMTPClientSession.h
//
// $Id: //poco/1.4/NetSSL_OpenSSL/include/Poco/Net/SecureSMTPClientSession.h#1 $
//
// Library: NetSSL_OpenSSL
// Package: Mail
// Module: SecureSMTPClientSession
//
// Definition of the SecureSMTPClientSession class.
//
// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_SecureSMTPClientSession_INCLUDED
#define Net_SecureSMTPClientSession_INCLUDED
#include "Poco/Net/NetSSL.h"
#include "Poco/Net/SMTPClientSession.h"
#include "Poco/Net/Context.h"
namespace Poco {
namespace Net {
class NetSSL_API SecureSMTPClientSession: public SMTPClientSession
/// This class implements an Simple Mail
/// Transfer Procotol (SMTP, RFC 2821)
/// client for sending e-mail messages that
/// supports the STARTTLS command for secure
/// connections.
///
/// Usage is as follows:
/// 1. Create a SecureSMTPClientSession object.
/// 2. Call login() or login(hostname).
/// 3. Call startTLS() to switch to a secure connection.
/// Check the return value to see if a secure connection
/// has actually been established (not all servers may
/// support STARTTLS).
/// 4. Call any of the login() methods to securely authenticate
/// with a username and password.
/// 5. Send the message(s).
{
public:
explicit SecureSMTPClientSession(const StreamSocket& socket);
/// Creates the SecureSMTPClientSession using
/// the given socket, which must be connected
/// to a SMTP server.
SecureSMTPClientSession(const std::string& host, Poco::UInt16 port = SMTP_PORT);
/// Creates the SecureSMTPClientSession using a socket connected
/// to the given host and port.
virtual ~SecureSMTPClientSession();
/// Destroys the SMTPClientSession.
bool startTLS();
/// Sends a STARTTLS command and, if successful,
/// creates a secure SSL/TLS connection over the
/// existing socket connection.
///
/// Must be called after login() or login(hostname).
/// If successful, login() can be called again
/// to authenticate the user.
///
/// Returns true if the STARTTLS command was successful,
/// false otherwise.
bool startTLS(Context::Ptr pContext);
/// Sends a STARTTLS command and, if successful,
/// creates a secure SSL/TLS connection over the
/// existing socket connection.
///
/// Uses the given Context object for creating
/// the SSL/TLS connection.
///
/// Must be called after login() or login(hostname).
/// If successful, login() can be called again
/// to authenticate the user.
///
/// Returns true if the STARTTLS command was successful,
/// false otherwise.
};
} } // namespace Poco::Net
#endif // Net_SecureSMTPClientSession_INCLUDED

View File

@@ -1,148 +1,158 @@
// //
// SecureServerSocket.h // SecureServerSocket.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureServerSocket.h#7 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureServerSocket.h#7 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLSockets // Package: SSLSockets
// Module: SecureServerSocket // Module: SecureServerSocket
// //
// Definition of the SecureServerSocket class. // Definition of the SecureServerSocket class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_SecureServerSocket_INCLUDED #ifndef NetSSL_SecureServerSocket_INCLUDED
#define NetSSL_SecureServerSocket_INCLUDED #define NetSSL_SecureServerSocket_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/Net/ServerSocket.h" #include "Poco/Net/ServerSocket.h"
#include "Poco/Net/Context.h" #include "Poco/Net/Context.h"
namespace Poco { namespace Poco {
namespace Net { namespace Net {
class NetSSL_API SecureServerSocket: public ServerSocket class NetSSL_API SecureServerSocket: public ServerSocket
/// A server socket for secure SSL connections. /// A server socket for secure SSL connections.
{ {
public: public:
SecureServerSocket(); SecureServerSocket();
/// Creates a SSL server socket using the /// Creates a SSL server socket using the
/// default SSL server context. /// default SSL server context.
/// ///
/// The server socket must be bound to /// The server socket must be bound to
/// an address and put into listening state. /// an address and put into listening state.
explicit SecureServerSocket(Context::Ptr pContext); explicit SecureServerSocket(Context::Ptr pContext);
/// Creates a SSL server socket, using the /// Creates a SSL server socket, using the
/// given SSL context object. /// given SSL context object.
/// ///
/// The server socket must be bound to /// The server socket must be bound to
/// an address and put into listening state. /// an address and put into listening state.
SecureServerSocket(const Socket& socket); SecureServerSocket(const Socket& socket);
/// Creates the SecureServerSocket with the SocketImpl /// Creates the SecureServerSocket with the SocketImpl
/// from another socket. The SocketImpl must be /// from another socket. The SocketImpl must be
/// a SecureServerSocketImpl, otherwise an InvalidArgumentException /// a SecureServerSocketImpl, otherwise an InvalidArgumentException
/// will be thrown. /// will be thrown.
SecureServerSocket(const SocketAddress& address, int backlog = 64); SecureServerSocket(const SocketAddress& address, int backlog = 64);
/// Creates a server socket using the default server SSL context, /// Creates a server socket using the default server SSL context,
/// binds it to the given address and puts it in listening /// binds it to the given address and puts it in listening
/// state. /// state.
/// ///
/// After successful construction, the server socket /// After successful construction, the server socket
/// is ready to accept connections. /// is ready to accept connections.
SecureServerSocket(const SocketAddress& address, int backlog, Context::Ptr pContext); SecureServerSocket(const SocketAddress& address, int backlog, Context::Ptr pContext);
/// Creates a server socket using the given SSL context, binds it /// Creates a server socket using the given SSL context, binds it
/// to the given address and puts it in listening /// to the given address and puts it in listening
/// state. /// state.
/// ///
/// After successful construction, the server socket /// After successful construction, the server socket
/// is ready to accept connections. /// is ready to accept connections.
SecureServerSocket(Poco::UInt16 port, int backlog = 64); SecureServerSocket(Poco::UInt16 port, int backlog = 64);
/// Creates a server socket using the default server SSL context, /// Creates a server socket using the default server SSL context,
/// binds it to the given port and puts it in listening /// binds it to the given port and puts it in listening
/// state. /// state.
/// ///
/// After successful construction, the server socket /// After successful construction, the server socket
/// is ready to accept connections. /// is ready to accept connections.
SecureServerSocket(Poco::UInt16 port, int backlog, Context::Ptr pContext); SecureServerSocket(Poco::UInt16 port, int backlog, Context::Ptr pContext);
/// Creates a server socket using the given SSL context, binds it /// Creates a server socket using the given SSL context, binds it
/// to the given port and puts it in listening /// to the given port and puts it in listening
/// state. /// state.
/// ///
/// After successful construction, the server socket /// After successful construction, the server socket
/// is ready to accept connections. /// is ready to accept connections.
virtual ~SecureServerSocket(); virtual ~SecureServerSocket();
/// Destroys the StreamSocket. /// Destroys the StreamSocket.
SecureServerSocket& operator = (const Socket& socket); SecureServerSocket& operator = (const Socket& socket);
/// Assignment operator. /// Assignment operator.
/// ///
/// Releases the socket's SocketImpl and /// Releases the socket's SocketImpl and
/// attaches the SocketImpl from the other socket and /// attaches the SocketImpl from the other socket and
/// increments the reference count of the SocketImpl. /// increments the reference count of the SocketImpl.
StreamSocket acceptConnection(SocketAddress& clientAddr); StreamSocket acceptConnection(SocketAddress& clientAddr);
/// Get the next completed connection from the /// Get the next completed connection from the
/// socket's completed connection queue. /// socket's completed connection queue.
/// ///
/// If the queue is empty, waits until a connection /// If the queue is empty, waits until a connection
/// request completes. /// request completes.
/// ///
/// Returns a new SSL socket for the connection /// Returns a new SSL socket for the connection
/// with the client. /// with the client.
/// ///
/// The client socket's address is returned in clientAddr. /// The client socket's address is returned in clientAddr.
///
StreamSocket acceptConnection(); /// No SSL handshake is performed on the new connection.
/// Get the next completed connection from the /// The SSL handshake will be performed the first time
/// socket's completed connection queue. /// sendBytes(), receiveBytes() or completeHandshake()
/// /// is called on the returned SecureStreamSocket.
/// If the queue is empty, waits until a connection
/// request completes. StreamSocket acceptConnection();
/// /// Get the next completed connection from the
/// Returns a new SSL socket for the connection /// socket's completed connection queue.
/// with the client. ///
/// If the queue is empty, waits until a connection
Context::Ptr context() const; /// request completes.
/// Returns the SSL context used by this socket. ///
}; /// Returns a new SSL socket for the connection
/// with the client.
///
} } // namespace Poco::Net /// No SSL handshake is performed on the new connection.
/// The SSL handshake will be performed the first time
/// sendBytes(), receiveBytes() or completeHandshake()
#endif // NetSSL_SecureServerSocket_INCLUDED /// is called on the returned SecureStreamSocket.
Context::Ptr context() const;
/// Returns the SSL context used by this socket.
};
} } // namespace Poco::Net
#endif // NetSSL_SecureServerSocket_INCLUDED

View File

@@ -1,164 +1,168 @@
// //
// SecureServerSocketImpl.h // SecureServerSocketImpl.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureServerSocketImpl.h#7 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureServerSocketImpl.h#7 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLSockets // Package: SSLSockets
// Module: SecureServerSocketImpl // Module: SecureServerSocketImpl
// //
// Definition of the SecureServerSocketImpl class. // Definition of the SecureServerSocketImpl class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_SecureServerSocketImpl_INCLUDED #ifndef NetSSL_SecureServerSocketImpl_INCLUDED
#define NetSSL_SecureServerSocketImpl_INCLUDED #define NetSSL_SecureServerSocketImpl_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/Net/SecureSocketImpl.h" #include "Poco/Net/SecureSocketImpl.h"
#include "Poco/Net/ServerSocketImpl.h" #include "Poco/Net/ServerSocketImpl.h"
#include "Poco/Net/Context.h" #include "Poco/Net/Context.h"
namespace Poco { namespace Poco {
namespace Net { namespace Net {
class NetSSL_API SecureServerSocketImpl: public ServerSocketImpl class NetSSL_API SecureServerSocketImpl: public ServerSocketImpl
/// The SocketImpl class for SecureServerSocket. /// The SocketImpl class for SecureServerSocket.
{ {
public: public:
SecureServerSocketImpl(Context::Ptr pContext); SecureServerSocketImpl(Context::Ptr pContext);
/// Creates the SecureServerSocketImpl using the /// Creates the SecureServerSocketImpl using the
/// given SSL context object. /// given SSL context object.
SocketImpl* acceptConnection(SocketAddress& clientAddr); SocketImpl* acceptConnection(SocketAddress& clientAddr);
/// Get the next completed connection from the /// Get the next completed connection from the
/// socket's completed connection queue. /// socket's completed connection queue.
/// ///
/// If the queue is empty, waits until a connection /// If the queue is empty, waits until a connection
/// request completes. /// request completes.
/// ///
/// Returns a new TCP socket for the connection /// Returns a new TCP socket for the connection
/// with the client. /// with the client.
/// ///
/// The client socket's address is returned in clientAddr. /// The client socket's address is returned in clientAddr.
void connect(const SocketAddress& address); void connect(const SocketAddress& address);
/// Not supported by this kind of socket. /// Not supported by this kind of socket.
/// ///
/// Throws a Poco::InvalidAccessException. /// Throws a Poco::InvalidAccessException.
void connect(const SocketAddress& address, const Poco::Timespan& timeout); void connect(const SocketAddress& address, const Poco::Timespan& timeout);
/// Not supported by this kind of socket. /// Not supported by this kind of socket.
/// ///
/// Throws a Poco::InvalidAccessException. /// Throws a Poco::InvalidAccessException.
void connectNB(const SocketAddress& address); void connectNB(const SocketAddress& address);
/// Not supported by this kind of socket. /// Not supported by this kind of socket.
/// ///
/// Throws a Poco::InvalidAccessException. /// Throws a Poco::InvalidAccessException.
void bind(const SocketAddress& address, bool reuseAddress = false); void bind(const SocketAddress& address, bool reuseAddress = false);
/// Bind a local address to the socket. /// Bind a local address to the socket.
/// ///
/// This is usually only done when establishing a server /// This is usually only done when establishing a server
/// socket. TCP clients should not bind a socket to a /// socket. TCP clients should not bind a socket to a
/// specific address. /// specific address.
/// ///
/// If reuseAddress is true, sets the SO_REUSEADDR /// If reuseAddress is true, sets the SO_REUSEADDR
/// socket option. /// socket option.
void listen(int backlog = 64); void listen(int backlog = 64);
/// Puts the socket into listening state. /// Puts the socket into listening state.
/// ///
/// The socket becomes a passive socket that /// The socket becomes a passive socket that
/// can accept incoming connection requests. /// can accept incoming connection requests.
/// ///
/// The backlog argument specifies the maximum /// The backlog argument specifies the maximum
/// number of connections that can be queued /// number of connections that can be queued
/// for this socket. /// for this socket.
void close(); void close();
/// Close the socket. /// Close the socket.
int sendBytes(const void* buffer, int length, int flags = 0); int sendBytes(const void* buffer, int length, int flags = 0);
/// Not supported by this kind of socket. /// Not supported by this kind of socket.
/// ///
/// Throws a Poco::InvalidAccessException. /// Throws a Poco::InvalidAccessException.
int receiveBytes(void* buffer, int length, int flags = 0); int receiveBytes(void* buffer, int length, int flags = 0);
/// Not supported by this kind of socket. /// Not supported by this kind of socket.
/// ///
/// Throws a Poco::InvalidAccessException. /// Throws a Poco::InvalidAccessException.
int sendTo(const void* buffer, int length, const SocketAddress& address, int flags = 0); int sendTo(const void* buffer, int length, const SocketAddress& address, int flags = 0);
/// Not supported by this kind of socket. /// Not supported by this kind of socket.
/// ///
/// Throws a Poco::InvalidAccessException. /// Throws a Poco::InvalidAccessException.
int receiveFrom(void* buffer, int length, SocketAddress& address, int flags = 0); int receiveFrom(void* buffer, int length, SocketAddress& address, int flags = 0);
/// Not supported by this kind of socket. /// Not supported by this kind of socket.
/// ///
/// Throws a Poco::InvalidAccessException. /// Throws a Poco::InvalidAccessException.
void sendUrgent(unsigned char data); void sendUrgent(unsigned char data);
/// Not supported by this kind of socket. /// Not supported by this kind of socket.
/// ///
/// Throws a Poco::InvalidAccessException. /// Throws a Poco::InvalidAccessException.
Context::Ptr context() const; bool secure() const;
/// Returns the SSL context used by this socket. /// Returns true iff the socket's connection is secure
/// (using SSL or TLS).
protected:
~SecureServerSocketImpl(); Context::Ptr context() const;
/// Destroys the SecureServerSocketImpl. /// Returns the SSL context used by this socket.
private: protected:
SecureServerSocketImpl(const SecureServerSocketImpl&); ~SecureServerSocketImpl();
SecureServerSocketImpl& operator = (const SecureServerSocketImpl&); /// Destroys the SecureServerSocketImpl.
private: private:
SecureSocketImpl _impl; SecureServerSocketImpl(const SecureServerSocketImpl&);
}; SecureServerSocketImpl& operator = (const SecureServerSocketImpl&);
private:
// SecureSocketImpl _impl;
// inlines };
//
inline Context::Ptr SecureServerSocketImpl::context() const
{ //
return _impl.context(); // inlines
} //
inline Context::Ptr SecureServerSocketImpl::context() const
{
} } // namespace Poco::Net return _impl.context();
}
#endif // NetSSL_SecureServerSocketImpl_INCLUDED
} } // namespace Poco::Net
#endif // NetSSL_SecureServerSocketImpl_INCLUDED

View File

@@ -1,190 +1,271 @@
// //
// SecureSocketImpl.h // SecureSocketImpl.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureSocketImpl.h#8 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureSocketImpl.h#8 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLSockets // Package: SSLSockets
// Module: SecureSocketImpl // Module: SecureSocketImpl
// //
// Definition of the SecureSocketImpl class. // Definition of the SecureSocketImpl class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_SecureSocketImpl_INCLUDED #ifndef NetSSL_SecureSocketImpl_INCLUDED
#define NetSSL_SecureSocketImpl_INCLUDED #define NetSSL_SecureSocketImpl_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/Net/SocketImpl.h" #include "Poco/Net/SocketImpl.h"
#include "Poco/Net/Context.h" #include "Poco/Net/Context.h"
#include "Poco/Net/X509Certificate.h" #include "Poco/Net/X509Certificate.h"
#include <openssl/bio.h> #include "Poco/Net/Session.h"
#include <openssl/ssl.h> #include <openssl/bio.h>
#include <openssl/ssl.h>
namespace Poco {
namespace Net { namespace Poco {
namespace Net {
class HostEntry;
class HostEntry;
class NetSSL_API SecureSocketImpl
/// The SocketImpl for SecureStreamSocket. class NetSSL_API SecureSocketImpl
{ /// The SocketImpl for SecureStreamSocket.
public: {
SecureSocketImpl(Poco::AutoPtr<SocketImpl> pSocketImpl, Context::Ptr pContext); public:
/// Creates the SecureSocketImpl using an already SecureSocketImpl(Poco::AutoPtr<SocketImpl> pSocketImpl, Context::Ptr pContext);
/// connected stream socket. /// Creates the SecureSocketImpl using an already
/// connected stream socket.
virtual ~SecureSocketImpl();
/// Destroys the SecureSocketImpl. virtual ~SecureSocketImpl();
/// Destroys the SecureSocketImpl.
SocketImpl* acceptConnection(SocketAddress& clientAddr);
/// Get the next completed connection from the SocketImpl* acceptConnection(SocketAddress& clientAddr);
/// socket's completed connection queue. /// Get the next completed connection from the
/// /// socket's completed connection queue.
/// If the queue is empty, waits until a connection ///
/// request completes. /// If the queue is empty, waits until a connection
/// /// request completes.
/// Returns a new SSL socket for the connection ///
/// with the client. /// Returns a new SSL socket for the connection
/// /// with the client.
/// The client socket's address is returned in clientAddr. ///
/// The client socket's address is returned in clientAddr.
void acceptSSL();
/// Performs a server-side SSL handshake and certificate verification. void connect(const SocketAddress& address, bool performHandshake);
/// Initializes the socket and establishes a secure connection to
void connect(const SocketAddress& address, const std::string& hostName); /// the TCP server at the given address.
/// Initializes the socket and establishes a secure connection to ///
/// the TCP server at the given address. /// If performHandshake is true, the SSL handshake is performed immediately
/// after establishing the connection. Otherwise, the handshake is performed
void connect(const SocketAddress& address, const std::string& hostName, const Poco::Timespan& timeout); /// the first time sendBytes(), receiveBytes() or completeHandshake() is called.
/// Initializes the socket, sets the socket timeout and
/// establishes a secure connection to the TCP server at the given address. void connect(const SocketAddress& address, const Poco::Timespan& timeout, bool performHandshake);
/// Initializes the socket, sets the socket timeout and
void connectNB(const SocketAddress& address, const std::string& hostName); /// establishes a secure connection to the TCP server at the given address.
/// Initializes the socket and establishes a secure connection to ///
/// the TCP server at the given address. Prior to opening the /// If performHandshake is true, the SSL handshake is performed immediately
/// connection the socket is set to nonblocking mode. /// after establishing the connection. Otherwise, the handshake is performed
/// the first time sendBytes(), receiveBytes() or completeHandshake() is called.
void connectSSL(const std::string& hostName);
/// Performs a client-side SSL handshake and establishes a secure void connectNB(const SocketAddress& address);
/// connection over an already existing TCP connection. /// Initializes the socket and establishes a secure connection to
/// the TCP server at the given address. Prior to opening the
void bind(const SocketAddress& address, bool reuseAddress = false); /// connection the socket is set to nonblocking mode.
/// Bind a local address to the socket.
/// void bind(const SocketAddress& address, bool reuseAddress = false);
/// This is usually only done when establishing a server /// Bind a local address to the socket.
/// socket. SSL clients should not bind a socket to a ///
/// specific address. /// This is usually only done when establishing a server
/// /// socket. SSL clients should not bind a socket to a
/// If reuseAddress is true, sets the SO_REUSEADDR /// specific address.
/// socket option. ///
/// If reuseAddress is true, sets the SO_REUSEADDR
void listen(int backlog = 64); /// socket option.
/// Puts the socket into listening state.
/// void listen(int backlog = 64);
/// The socket becomes a passive socket that /// Puts the socket into listening state.
/// can accept incoming connection requests. ///
/// /// The socket becomes a passive socket that
/// The backlog argument specifies the maximum /// can accept incoming connection requests.
/// number of connections that can be queued ///
/// for this socket. /// The backlog argument specifies the maximum
/// number of connections that can be queued
void shutdown(); /// for this socket.
/// Shuts down the connection by attempting
/// an orderly SSL shutdown, then actually void shutdown();
/// shutting down the TCP connection. /// Shuts down the connection by attempting
/// an orderly SSL shutdown, then actually
void close(); /// shutting down the TCP connection.
/// Close the socket.
void close();
int sendBytes(const void* buffer, int length, int flags = 0); /// Close the socket.
/// Sends the contents of the given buffer through
/// the socket. Any specified flags are ignored. void abort();
/// /// Aborts the connection by closing the
/// Returns the number of bytes sent, which may be /// underlying TCP connection. No orderly SSL shutdown
/// less than the number of bytes specified. /// is performed.
int receiveBytes(void* buffer, int length, int flags = 0); int sendBytes(const void* buffer, int length, int flags = 0);
/// Receives data from the socket and stores it /// Sends the contents of the given buffer through
/// in buffer. Up to length bytes are received. /// the socket. Any specified flags are ignored.
/// ///
/// Returns the number of bytes received. /// Returns the number of bytes sent, which may be
/// less than the number of bytes specified.
poco_socket_t sockfd();
/// Returns the underlying socket descriptor. int receiveBytes(void* buffer, int length, int flags = 0);
/// Receives data from the socket and stores it
X509* peerCertificate() const; /// in buffer. Up to length bytes are received.
/// Returns the peer's certificate. ///
/// Returns the number of bytes received.
Context::Ptr context() const;
/// Returns the SSL context used for this socket. int available() const;
/// Returns the number of bytes available from the
protected: /// SSL buffer for immediate reading.
long verifyCertificate(const std::string& hostName);
/// PostConnectionCheck to verify that a peer really presented a valid certificate. int completeHandshake();
/// Completes the SSL handshake.
static bool isLocalHost(const std::string& hostName); ///
/// Returns true iff the given host name is the local host /// If the SSL connection was the result of an accept(),
/// (either "localhost" or "127.0.0.1"). /// the server-side handshake is completed, otherwise
/// a client-side handshake is performed.
int handleError(int rc);
/// Handles an SSL error by throwing an appropriate exception. poco_socket_t sockfd();
/// Returns the underlying socket descriptor.
private:
SecureSocketImpl(const SecureSocketImpl&); X509* peerCertificate() const;
SecureSocketImpl& operator = (const SecureSocketImpl&); /// Returns the peer's certificate.
SSL* _pSSL; Context::Ptr context() const;
Poco::AutoPtr<SocketImpl> _pSocket; /// Returns the SSL context used for this socket.
Context::Ptr _pContext;
}; void verifyPeerCertificate();
/// Performs post-connect (or post-accept) peer certificate validation,
/// using the peer host name set with setPeerHostName(), or the peer's
// /// IP address string if no peer host name has been set.
// inlines
// void verifyPeerCertificate(const std::string& hostName);
inline poco_socket_t SecureSocketImpl::sockfd() /// Performs post-connect (or post-accept) peer certificate validation
{ /// using the given peer host name.
return _pSocket->sockfd();
} void setPeerHostName(const std::string& hostName);
/// Sets the peer host name for certificate validation purposes.
inline Context::Ptr SecureSocketImpl::context() const const std::string& getPeerHostName() const;
{ /// Returns the peer host name.
return _pContext;
} Session::Ptr currentSession();
/// Returns the SSL session of the current connection,
/// for reuse in a future connection (if session caching
} } // namespace Poco::Net /// is enabled).
///
/// If no connection is established, returns null.
#endif // NetSSL_SecureSocketImpl_INCLUDED
void useSession(Session::Ptr pSession);
/// Sets the SSL session to use for the next
/// connection. Setting a previously saved Session
/// object is necessary to enable session caching.
///
/// To remove the currently set session, a null pointer
/// can be given.
///
/// Must be called before connect() to be effective.
bool sessionWasReused();
/// Returns true iff a reused session was negotiated during
/// the handshake.
protected:
void acceptSSL();
/// Performs a server-side SSL handshake and certificate verification.
void connectSSL(bool performHandshake);
/// Performs a client-side SSL handshake and establishes a secure
/// connection over an already existing TCP connection.
long verifyPeerCertificateImpl(const std::string& hostName);
/// Performs post-connect (or post-accept) peer certificate validation.
static bool isLocalHost(const std::string& hostName);
/// Returns true iff the given host name is the local host
/// (either "localhost" or "127.0.0.1").
int handleError(int rc);
/// Handles an SSL error by throwing an appropriate exception.
void reset();
/// Prepares the socket for re-use.
///
/// After closing and resetting a socket, the socket can
/// be used for a new connection.
///
/// Note that simply closing a socket is not sufficient
/// to be able to re-use it again.
private:
SecureSocketImpl(const SecureSocketImpl&);
SecureSocketImpl& operator = (const SecureSocketImpl&);
SSL* _pSSL;
Poco::AutoPtr<SocketImpl> _pSocket;
Context::Ptr _pContext;
bool _needHandshake;
std::string _peerHostName;
Session::Ptr _pSession;
friend class SecureStreamSocketImpl;
};
//
// inlines
//
inline poco_socket_t SecureSocketImpl::sockfd()
{
return _pSocket->sockfd();
}
inline Context::Ptr SecureSocketImpl::context() const
{
return _pContext;
}
inline const std::string& SecureSocketImpl::getPeerHostName() const
{
return _peerHostName;
}
} } // namespace Poco::Net
#endif // NetSSL_SecureSocketImpl_INCLUDED

View File

@@ -1,175 +1,294 @@
// //
// SecureStreamSocket.h // SecureStreamSocket.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureStreamSocket.h#7 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureStreamSocket.h#7 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLSockets // Package: SSLSockets
// Module: SecureStreamSocket // Module: SecureStreamSocket
// //
// Definition of the SecureStreamSocket class. // Definition of the SecureStreamSocket class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_SecureStreamSocket_INCLUDED #ifndef NetSSL_SecureStreamSocket_INCLUDED
#define NetSSL_SecureStreamSocket_INCLUDED #define NetSSL_SecureStreamSocket_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/Net/StreamSocket.h" #include "Poco/Net/StreamSocket.h"
#include "Poco/Net/Context.h" #include "Poco/Net/Context.h"
#include "Poco/Net/X509Certificate.h" #include "Poco/Net/Session.h"
#include "Poco/Net/X509Certificate.h"
namespace Poco {
namespace Net { namespace Poco {
namespace Net {
class NetSSL_API SecureStreamSocket: public StreamSocket
/// A subclass of StreamSocket for secure SSL sockets. class NetSSL_API SecureStreamSocket: public StreamSocket
/// /// A subclass of StreamSocket for secure SSL sockets.
/// A few notes about nonblocking IO: ///
/// sendBytes() and receiveBytes() can return a /// A few notes about nonblocking IO:
/// negative value when using a nonblocking socket, which means /// sendBytes() and receiveBytes() can return a
/// a SSL handshake is currently in progress and more data /// negative value when using a nonblocking socket, which means
/// needs to be read or written for the handshake to continue. /// a SSL handshake is currently in progress and more data
/// If sendBytes() or receiveBytes() return ERR_SSL_WANT_WRITE, /// needs to be read or written for the handshake to continue.
/// sendBytes() must be called as soon as possible (usually, after /// If sendBytes() or receiveBytes() return ERR_SSL_WANT_WRITE,
/// select() indicates that data can be written). Likewise, if /// sendBytes() must be called as soon as possible (usually, after
/// ERR_SSL_WANT_READ is returned, receiveBytes() must be called /// select() indicates that data can be written). Likewise, if
/// as soon as data is available for reading (indicated by select()). /// ERR_SSL_WANT_READ is returned, receiveBytes() must be called
/// /// as soon as data is available for reading (indicated by select()).
/// The SSL handshake is delayed until the first sendBytes() or ///
/// receiveBytes() operation is performed on the socket. No automatic /// The SSL handshake is delayed until the first sendBytes() or
/// post connection check (checking the peer certificate for a valid /// receiveBytes() operation is performed on the socket. No automatic
/// hostname) is performed when using nonblocking I/O. /// post connection check (checking the peer certificate for a valid
{ /// hostname) is performed when using nonblocking I/O. To manually
public: /// perform peer certificate validation, call verifyPeerCertificate()
enum /// after the SSL handshake has been completed.
{ {
ERR_SSL_WANT_READ = -1, public:
ERR_SSL_WANT_WRITE = -2 enum
}; {
ERR_SSL_WANT_READ = -1,
SecureStreamSocket(); ERR_SSL_WANT_WRITE = -2
/// Creates an unconnected secure stream socket };
/// using the default client SSL context.
/// SecureStreamSocket();
/// Before sending or receiving data, the socket /// Creates an unconnected secure stream socket
/// must be connected with a call to connect(). /// using the default client SSL context.
///
explicit SecureStreamSocket(Context::Ptr pContext); /// Before sending or receiving data, the socket
/// Creates an unconnected secure stream socket /// must be connected with a call to connect().
/// using the given SSL context.
/// explicit SecureStreamSocket(Context::Ptr pContext);
/// Before sending or receiving data, the socket /// Creates an unconnected secure stream socket
/// must be connected with a call to connect(). /// using the given SSL context.
///
explicit SecureStreamSocket(const SocketAddress& address); /// Before sending or receiving data, the socket
/// Creates a secure stream socket using the default /// must be connected with a call to connect().
/// client SSL context and connects it to
/// the socket specified by address. SecureStreamSocket(Context::Ptr pContext, Session::Ptr pSession);
/// Creates an unconnected secure stream socket
SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext); /// using the given SSL context.
/// Creates a secure stream socket using the given ///
/// client SSL context and connects it to /// Before sending or receiving data, the socket
/// the socket specified by address. /// must be connected with a call to connect().
///
SecureStreamSocket(const SocketAddress& address, const std::string& hostName); /// The given Session is reused, if possible (client session
/// Creates a secure stream socket using the default /// caching is enabled for the given Context, and the server
/// client SSL context and connects it to /// agrees to reuse the session).
/// the socket specified by address.
/// explicit SecureStreamSocket(const SocketAddress& address);
/// The given host name is used for certificate verification. /// Creates a secure stream socket using the default
/// client SSL context and connects it to
SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext); /// the socket specified by address.
/// Creates a secure stream socket using the given
/// client SSL context and connects it to SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext);
/// the socket specified by address. /// Creates a secure stream socket using the given
/// /// client SSL context and connects it to
/// The given host name is used for certificate verification. /// the socket specified by address.
SecureStreamSocket(const Socket& socket); SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext, Session::Ptr pSession);
/// Creates the SecureStreamSocket with the SocketImpl /// Creates a secure stream socket using the given
/// from another socket. The SocketImpl must be /// client SSL context and connects it to
/// a SecureStreamSocketImpl, otherwise an InvalidArgumentException /// the socket specified by address.
/// will be thrown. ///
/// The given Session is reused, if possible (client session
virtual ~SecureStreamSocket(); /// caching is enabled for the given Context, and the server
/// Destroys the StreamSocket. /// agrees to reuse the session).
SecureStreamSocket& operator = (const Socket& socket); SecureStreamSocket(const SocketAddress& address, const std::string& hostName);
/// Assignment operator. /// Creates a secure stream socket using the default
/// /// client SSL context and connects it to
/// Releases the socket's SocketImpl and /// the socket specified by address.
/// attaches the SocketImpl from the other socket and ///
/// increments the reference count of the SocketImpl. /// The given host name is used for certificate verification.
X509Certificate peerCertificate() const; SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext);
/// Returns the peer's X509 certificate. /// Creates a secure stream socket using the given
/// client SSL context and connects it to
void setPeerHostName(const std::string& hostName); /// the socket specified by address.
/// Sets the peer's host name used for certificate validation. ///
/// The given host name is used for certificate verification.
const std::string& getPeerHostName() const;
/// Returns the peer's host name used for certificate validation. SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext, Session::Ptr pSession);
/// Creates a secure stream socket using the given
static SecureStreamSocket attach(const StreamSocket& streamSocket); /// client SSL context and connects it to
/// Creates a SecureStreamSocket over an existing socket /// the socket specified by address.
/// connection. The given StreamSocket must be connected. ///
/// A SSL handshake will be performed. /// The given host name is used for certificate verification.
///
static SecureStreamSocket attach(const StreamSocket& streamSocket, Context::Ptr pContext); /// The given Session is reused, if possible (client session
/// Creates a SecureStreamSocket over an existing socket /// caching is enabled for the given Context, and the server
/// connection. The given StreamSocket must be connected. /// agrees to reuse the session).
/// A SSL handshake will be performed.
SecureStreamSocket(const Socket& socket);
static SecureStreamSocket attach(const StreamSocket& streamSocket, const std::string& peerHostName); /// Creates the SecureStreamSocket with the SocketImpl
/// Creates a SecureStreamSocket over an existing socket /// from another socket. The SocketImpl must be
/// connection. The given StreamSocket must be connected. /// a SecureStreamSocketImpl, otherwise an InvalidArgumentException
/// A SSL handshake will be performed. /// will be thrown.
static SecureStreamSocket attach(const StreamSocket& streamSocket, const std::string& peerHostName, Context::Ptr pContext); virtual ~SecureStreamSocket();
/// Creates a SecureStreamSocket over an existing socket /// Destroys the StreamSocket.
/// connection. The given StreamSocket must be connected.
/// A SSL handshake will be performed. SecureStreamSocket& operator = (const Socket& socket);
/// Assignment operator.
Context::Ptr context() const; ///
/// Returns the SSL context used by this socket. /// Releases the socket's SocketImpl and
/// attaches the SocketImpl from the other socket and
protected: /// increments the reference count of the SocketImpl.
SecureStreamSocket(SocketImpl* pImpl);
bool havePeerCertificate() const;
friend class SecureServerSocket; /// Returns true iff the peer has presented a
}; /// certificate.
X509Certificate peerCertificate() const;
} } // namespace Poco::Net /// Returns the peer's X509 certificate.
///
/// Throws a SSLException if the peer did not
#endif // NetSSL_SecureStreamSocket_INCLUDED /// present a certificate.
void setPeerHostName(const std::string& hostName);
/// Sets the peer's host name used for certificate validation.
const std::string& getPeerHostName() const;
/// Returns the peer's host name used for certificate validation.
static SecureStreamSocket attach(const StreamSocket& streamSocket);
/// Creates a SecureStreamSocket over an existing socket
/// connection. The given StreamSocket must be connected.
/// A SSL handshake will be performed.
static SecureStreamSocket attach(const StreamSocket& streamSocket, Context::Ptr pContext);
/// Creates a SecureStreamSocket over an existing socket
/// connection. The given StreamSocket must be connected.
/// A SSL handshake will be performed.
static SecureStreamSocket attach(const StreamSocket& streamSocket, Context::Ptr pContext, Session::Ptr pSession);
/// Creates a SecureStreamSocket over an existing socket
/// connection. The given StreamSocket must be connected.
/// A SSL handshake will be performed.
///
/// The given Session is reused, if possible (client session
/// caching is enabled for the given Context, and the server
/// agrees to reuse the session).
static SecureStreamSocket attach(const StreamSocket& streamSocket, const std::string& peerHostName);
/// Creates a SecureStreamSocket over an existing socket
/// connection. The given StreamSocket must be connected.
/// A SSL handshake will be performed.
static SecureStreamSocket attach(const StreamSocket& streamSocket, const std::string& peerHostName, Context::Ptr pContext);
/// Creates a SecureStreamSocket over an existing socket
/// connection. The given StreamSocket must be connected.
/// A SSL handshake will be performed.
static SecureStreamSocket attach(const StreamSocket& streamSocket, const std::string& peerHostName, Context::Ptr pContext, Session::Ptr pSession);
/// Creates a SecureStreamSocket over an existing socket
/// connection. The given StreamSocket must be connected.
/// A SSL handshake will be performed.
///
/// The given Session is reused, if possible (client session
/// caching is enabled for the given Context, and the server
/// agrees to reuse the session).
Context::Ptr context() const;
/// Returns the SSL context used by this socket.
void setLazyHandshake(bool flag = true);
/// Enable lazy SSL handshake. If enabled, the SSL handshake
/// will be performed the first time date is sent or
/// received over the connection.
bool getLazyHandshake() const;
/// Returns true if setLazyHandshake(true) has been called.
void verifyPeerCertificate();
/// Performs post-connect (or post-accept) peer certificate validation,
/// using the peer host name set with setPeerHostName(), or the peer's
/// IP address string if no peer host name has been set.
///
/// Should only be used for non-blocking connections, after the
/// initial SSL handshake has been performed (see completeHandshake()).
void verifyPeerCertificate(const std::string& hostName);
/// Performs post-connect (or post-accept) peer certificate validation
/// using the given host name.
///
/// Should only be used for non-blocking connections, after the
/// initial SSL handshake has been performed (see completeHandshake()).
int completeHandshake();
/// Completes the SSL handshake.
///
/// If the SSL connection was the result of an accept(),
/// the server-side handshake is completed, otherwise
/// a client-side handshake is performed.
///
/// Returns 1 if the handshake was successful, ERR_SSL_WANT_READ or
/// ERR_SSL_WANT_WRITE if more data is required to complete the
/// handshake. In this case, completeHandshake() should be called
/// again, after the necessary condition has been met.
Session::Ptr currentSession();
/// Returns the SSL session of the current connection,
/// for reuse in a future connection (if session caching
/// is enabled).
///
/// If no connection is established, returns null.
void useSession(Session::Ptr pSession);
/// Sets the SSL session to use for the next
/// connection. Setting a previously saved Session
/// object is necessary to enable session caching.
///
/// To remove the currently set session, a null pointer
/// can be given.
///
/// Must be called before connect() to be effective.
bool sessionWasReused();
/// Returns true iff a reused session was negotiated during
/// the handshake.
void abort();
/// Aborts the SSL connection by closing the underlying
/// TCP connection. No orderly SSL shutdown is performed.
protected:
SecureStreamSocket(SocketImpl* pImpl);
friend class SecureServerSocket;
};
} } // namespace Poco::Net
#endif // NetSSL_SecureStreamSocket_INCLUDED

View File

@@ -1,229 +1,321 @@
// //
// SecureStreamSocketImpl.h // SecureStreamSocketImpl.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureStreamSocketImpl.h#7 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureStreamSocketImpl.h#7 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLSockets // Package: SSLSockets
// Module: SecureStreamSocketImpl // Module: SecureStreamSocketImpl
// //
// Definition of the SecureStreamSocketImpl class. // Definition of the SecureStreamSocketImpl class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_SecureStreamSocketImpl_INCLUDED #ifndef NetSSL_SecureStreamSocketImpl_INCLUDED
#define NetSSL_SecureStreamSocketImpl_INCLUDED #define NetSSL_SecureStreamSocketImpl_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/Net/SecureSocketImpl.h" #include "Poco/Net/SecureSocketImpl.h"
#include "Poco/Net/StreamSocketImpl.h" #include "Poco/Net/StreamSocketImpl.h"
#include "Poco/Net/Context.h" #include "Poco/Net/Context.h"
#include "Poco/Net/X509Certificate.h" #include "Poco/Net/X509Certificate.h"
namespace Poco { namespace Poco {
namespace Net { namespace Net {
class NetSSL_API SecureStreamSocketImpl: public StreamSocketImpl class NetSSL_API SecureStreamSocketImpl: public StreamSocketImpl
/// This class implements a SSL stream socket. /// This class implements a SSL stream socket.
{ {
public: public:
SecureStreamSocketImpl(Context::Ptr pContext); SecureStreamSocketImpl(Context::Ptr pContext);
/// Creates the SecureStreamSocketImpl. /// Creates the SecureStreamSocketImpl.
SecureStreamSocketImpl(StreamSocketImpl* pStreamSocket, Context::Ptr pContext); SecureStreamSocketImpl(StreamSocketImpl* pStreamSocket, Context::Ptr pContext);
/// Creates the SecureStreamSocketImpl. /// Creates the SecureStreamSocketImpl.
SocketImpl* acceptConnection(SocketAddress& clientAddr); SocketImpl* acceptConnection(SocketAddress& clientAddr);
/// Not supported by a SecureStreamSocket. /// Not supported by a SecureStreamSocket.
/// ///
/// Throws a Poco::InvalidAccessException. /// Throws a Poco::InvalidAccessException.
void acceptSSL(); void connect(const SocketAddress& address);
/// Performs a SSL server-side handshake. /// Initializes the socket and establishes a connection to
/// the TCP server at the given address.
void connect(const SocketAddress& address); ///
/// Initializes the socket and establishes a connection to /// Can also be used for UDP sockets. In this case, no
/// the TCP server at the given address. /// connection is established. Instead, incoming and outgoing
/// /// packets are restricted to the specified address.
/// Can also be used for UDP sockets. In this case, no
/// connection is established. Instead, incoming and outgoing void connect(const SocketAddress& address, const Poco::Timespan& timeout);
/// packets are restricted to the specified address. /// Initializes the socket, sets the socket timeout and
/// establishes a connection to the TCP server at the given address.
void connect(const SocketAddress& address, const Poco::Timespan& timeout);
/// Initializes the socket, sets the socket timeout and void connectNB(const SocketAddress& address);
/// establishes a connection to the TCP server at the given address. /// Initializes the socket and establishes a connection to
/// the TCP server at the given address. Prior to opening the
void connectNB(const SocketAddress& address); /// connection the socket is set to nonblocking mode.
/// Initializes the socket and establishes a connection to
/// the TCP server at the given address. Prior to opening the void bind(const SocketAddress& address, bool reuseAddress = false);
/// connection the socket is set to nonblocking mode. /// Not supported by a SecureStreamSocket.
///
void connectSSL(); /// Throws a Poco::InvalidAccessException.
/// Performs a SSL client-side handshake on an already connected TCP socket.
void listen(int backlog = 64);
void bind(const SocketAddress& address, bool reuseAddress = false); /// Not supported by a SecureStreamSocket.
/// Not supported by a SecureStreamSocket. ///
/// /// Throws a Poco::InvalidAccessException.
/// Throws a Poco::InvalidAccessException.
void close();
void listen(int backlog = 64); /// Close the socket.
/// Not supported by a SecureStreamSocket.
/// int sendBytes(const void* buffer, int length, int flags = 0);
/// Throws a Poco::InvalidAccessException. /// Sends the contents of the given buffer through
/// the socket. Any specified flags are ignored.
void close(); ///
/// Close the socket. /// Returns the number of bytes sent, which may be
/// less than the number of bytes specified.
int sendBytes(const void* buffer, int length, int flags = 0);
/// Sends the contents of the given buffer through int receiveBytes(void* buffer, int length, int flags = 0);
/// the socket. Any specified flags are ignored. /// Receives data from the socket and stores it
/// /// in buffer. Up to length bytes are received.
/// Returns the number of bytes sent, which may be ///
/// less than the number of bytes specified. /// Returns the number of bytes received.
int receiveBytes(void* buffer, int length, int flags = 0); int sendTo(const void* buffer, int length, const SocketAddress& address, int flags = 0);
/// Receives data from the socket and stores it /// Not supported by a SecureStreamSocket.
/// in buffer. Up to length bytes are received. ///
/// /// Throws a Poco::InvalidAccessException.
/// Returns the number of bytes received.
int receiveFrom(void* buffer, int length, SocketAddress& address, int flags = 0);
int sendTo(const void* buffer, int length, const SocketAddress& address, int flags = 0); /// Not supported by a SecureStreamSocket.
/// Not supported by a SecureStreamSocket. ///
/// /// Throws a Poco::InvalidAccessException.
/// Throws a Poco::InvalidAccessException.
void sendUrgent(unsigned char data);
int receiveFrom(void* buffer, int length, SocketAddress& address, int flags = 0); /// Not supported by a SecureStreamSocket.
/// Not supported by a SecureStreamSocket. ///
/// /// Throws a Poco::InvalidAccessException.
/// Throws a Poco::InvalidAccessException.
int available();
void sendUrgent(unsigned char data); /// Returns the number of bytes available that can be read
/// Not supported by a SecureStreamSocket. /// without causing the socket to block.
/// ///
/// Throws a Poco::InvalidAccessException. /// For an SSL connection, returns the number of bytes that
/// can be read from the currently buffered SSL record,
void shutdownReceive(); /// before a new record is read from the underlying socket.
/// Shuts down the receiving part of the socket connection.
/// void shutdownReceive();
/// Since SSL does not support a half shutdown, this does /// Shuts down the receiving part of the socket connection.
/// nothing. ///
/// Since SSL does not support a half shutdown, this does
void shutdownSend(); /// nothing.
/// Shuts down the receiving part of the socket connection.
/// void shutdownSend();
/// Since SSL does not support a half shutdown, this does /// Shuts down the receiving part of the socket connection.
/// nothing. ///
/// Since SSL does not support a half shutdown, this does
void shutdown(); /// nothing.
/// Shuts down the SSL connection.
void shutdown();
void setPeerHostName(const std::string& hostName); /// Shuts down the SSL connection.
/// Sets the peer host name for certificate validation purposes.
void abort();
const std::string& getPeerHostName() const; /// Aborts the connection by closing the underlying
/// Returns the peer host name. /// TCP connection. No orderly SSL shutdown is performed.
X509Certificate peerCertificate() const; bool secure() const;
/// Returns the peer's X509 certificate. /// Returns true iff the socket's connection is secure
/// (using SSL or TLS).
Context::Ptr context() const;
/// Returns the SSL context used by this socket. void setPeerHostName(const std::string& hostName);
/// Sets the peer host name for certificate validation purposes.
protected:
~SecureStreamSocketImpl(); const std::string& getPeerHostName() const;
/// Destroys the SecureStreamSocketImpl. /// Returns the peer host name.
static int lastError(); bool havePeerCertificate() const;
static void error(); /// Returns true iff the peer has presented a
static void error(const std::string& arg); /// certificate.
static void error(int code);
static void error(int code, const std::string& arg); X509Certificate peerCertificate() const;
/// Returns the peer's X509 certificate.
private: ///
SecureStreamSocketImpl(const SecureStreamSocketImpl&); /// Throws a SSLException if the peer did not
SecureStreamSocketImpl& operator = (const SecureStreamSocketImpl&); /// present a certificate.
SecureSocketImpl _impl; Context::Ptr context() const;
std::string _peerHostName; /// Returns the SSL context used by this socket.
friend class SecureSocketImpl; void setLazyHandshake(bool flag = true);
}; /// Enable lazy SSL handshake. If enabled, the SSL handshake
/// will be performed the first time date is sent or
/// received over the connection.
//
// inlines bool getLazyHandshake() const;
// /// Returns true if setLazyHandshake(true) has been called.
inline const std::string& SecureStreamSocketImpl::getPeerHostName() const
{ void verifyPeerCertificate();
return _peerHostName; /// Performs post-connect (or post-accept) peer certificate validation,
} /// using the peer's IP address as host name.
void verifyPeerCertificate(const std::string& hostName);
inline Context::Ptr SecureStreamSocketImpl::context() const /// Performs post-connect (or post-accept) peer certificate validation
{ /// using the given host name.
return _impl.context();
} int completeHandshake();
/// Completes the SSL handshake.
///
inline int SecureStreamSocketImpl::lastError() /// If the SSL connection was the result of an accept(),
{ /// the server-side handshake is completed, otherwise
return SocketImpl::lastError(); /// a client-side handshake is performed.
}
Session::Ptr currentSession();
/// Returns the SSL session of the current connection,
inline void SecureStreamSocketImpl::error() /// for reuse in a future connection (if session caching
{ /// is enabled).
return SocketImpl::error(); ///
} /// If no connection is established, returns null.
void useSession(Session::Ptr pSession);
inline void SecureStreamSocketImpl::error(const std::string& arg) /// Sets the SSL session to use for the next
{ /// connection. Setting a previously saved Session
return SocketImpl::error(arg); /// object is necessary to enable session caching.
} ///
/// To remove the currently set session, a null pointer
/// can be given.
inline void SecureStreamSocketImpl::error(int code) ///
{ /// Must be called before connect() to be effective.
return SocketImpl::error(code);
} bool sessionWasReused();
/// Returns true iff a reused session was negotiated during
/// the handshake.
inline void SecureStreamSocketImpl::error(int code, const std::string& arg)
{ protected:
return SocketImpl::error(code, arg); void acceptSSL();
} /// Performs a SSL server-side handshake.
void connectSSL();
} } // namespace Poco::Net /// Performs a SSL client-side handshake on an already connected TCP socket.
~SecureStreamSocketImpl();
#endif // NetSSL_SecureStreamSocketImpl_INCLUDED /// Destroys the SecureStreamSocketImpl.
static int lastError();
static void error();
static void error(const std::string& arg);
static void error(int code);
static void error(int code, const std::string& arg);
private:
SecureStreamSocketImpl(const SecureStreamSocketImpl&);
SecureStreamSocketImpl& operator = (const SecureStreamSocketImpl&);
SecureSocketImpl _impl;
bool _lazyHandshake;
friend class SecureSocketImpl;
friend class SecureStreamSocket;
};
//
// inlines
//
inline const std::string& SecureStreamSocketImpl::getPeerHostName() const
{
return _impl.getPeerHostName();
}
inline void SecureStreamSocketImpl::setPeerHostName(const std::string& peerHostName)
{
_impl.setPeerHostName(peerHostName);
}
inline Context::Ptr SecureStreamSocketImpl::context() const
{
return _impl.context();
}
inline Session::Ptr SecureStreamSocketImpl::currentSession()
{
return _impl.currentSession();
}
inline void SecureStreamSocketImpl::useSession(Session::Ptr pSession)
{
_impl.useSession(pSession);
}
inline bool SecureStreamSocketImpl::sessionWasReused()
{
return _impl.sessionWasReused();
}
inline int SecureStreamSocketImpl::lastError()
{
return SocketImpl::lastError();
}
inline void SecureStreamSocketImpl::error()
{
return SocketImpl::error();
}
inline void SecureStreamSocketImpl::error(const std::string& arg)
{
return SocketImpl::error(arg);
}
inline void SecureStreamSocketImpl::error(int code)
{
return SocketImpl::error(code);
}
inline void SecureStreamSocketImpl::error(int code, const std::string& arg)
{
return SocketImpl::error(code, arg);
}
} } // namespace Poco::Net
#endif // NetSSL_SecureStreamSocketImpl_INCLUDED

View File

@@ -0,0 +1,101 @@
//
// Session.h
//
// $Id: //poco/1.4/NetSSL_OpenSSL/include/Poco/Net/Session.h#1 $
//
// Library: NetSSL_OpenSSL
// Package: SSLCore
// Module: Session
//
// Definition of the Session class.
//
// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef NetSSL_Session_INCLUDED
#define NetSSL_Session_INCLUDED
#include "Poco/Net/NetSSL.h"
#include "Poco/RefCountedObject.h"
#include "Poco/AutoPtr.h"
#include <openssl/ssl.h>
namespace Poco {
namespace Net {
class NetSSL_API Session: public Poco::RefCountedObject
/// This class encapsulates a SSL session object
/// used with session caching on the client side.
///
/// For session caching to work, a client must
/// save the session object from an existing connection,
/// if it wants to reuse it with a future connection.
{
public:
typedef Poco::AutoPtr<Session> Ptr;
SSL_SESSION* sslSession() const;
/// Returns the stored OpenSSL SSL_SESSION object.
protected:
Session(SSL_SESSION* pSession);
/// Creates a new Session object, using the given
/// SSL_SESSION object.
///
/// The SSL_SESSION's reference count is not changed.
~Session();
/// Destroys the Session.
///
/// Calls SSL_SESSION_free() on the stored
/// SSL_SESSION object.
private:
Session();
SSL_SESSION* _pSession;
friend class SecureSocketImpl;
};
//
// inlines
//
inline SSL_SESSION* Session::sslSession() const
{
return _pSession;
}
} } // namespace Poco::Net
#endif // NetSSL_Session_INCLUDED

View File

@@ -1,112 +1,124 @@
// //
// X509Certificate.h // X509Certificate.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/X509Certificate.h#12 $ // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/X509Certificate.h#12 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: X509Certificate // Module: X509Certificate
// //
// Definition of the X509Certificate class. // Definition of the X509Certificate class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef NetSSL_X509Certificate_INCLUDED #ifndef NetSSL_X509Certificate_INCLUDED
#define NetSSL_X509Certificate_INCLUDED #define NetSSL_X509Certificate_INCLUDED
#include "Poco/Net/NetSSL.h" #include "Poco/Net/NetSSL.h"
#include "Poco/Crypto/X509Certificate.h" #include "Poco/Net/SocketDefs.h"
#include "Poco/DateTime.h" #include "Poco/Crypto/X509Certificate.h"
#include "Poco/SharedPtr.h" #include "Poco/DateTime.h"
#include <set> #include "Poco/SharedPtr.h"
#include <openssl/ssl.h> #include <set>
namespace Poco { namespace Poco {
namespace Net { namespace Net {
class HostEntry; class HostEntry;
class NetSSL_API X509Certificate: public Poco::Crypto::X509Certificate class NetSSL_API X509Certificate: public Poco::Crypto::X509Certificate
/// This class extends Poco::Crypto::X509Certificate with the /// This class extends Poco::Crypto::X509Certificate with the
/// feature to validate a certificate. /// feature to validate a certificate.
{ {
public: public:
explicit X509Certificate(std::istream& istr); explicit X509Certificate(std::istream& istr);
/// Creates the X509Certificate object by reading /// Creates the X509Certificate object by reading
/// a certificate in PEM format from a stream. /// a certificate in PEM format from a stream.
explicit X509Certificate(const std::string& path); explicit X509Certificate(const std::string& path);
/// Creates the X509Certificate object by reading /// Creates the X509Certificate object by reading
/// a certificate in PEM format from a file. /// a certificate in PEM format from a file.
explicit X509Certificate(X509* pCert); explicit X509Certificate(X509* pCert);
/// Creates the X509Certificate from an existing /// Creates the X509Certificate from an existing
/// OpenSSL certificate. Ownership is taken of /// OpenSSL certificate. Ownership is taken of
/// the certificate. /// the certificate.
X509Certificate(const Poco::Crypto::X509Certificate& cert); X509Certificate(X509* pCert, bool shared);
/// Creates the certificate by copying another one. /// Creates the X509Certificate from an existing
/// OpenSSL certificate. Ownership is taken of
X509Certificate& operator = (const Poco::Crypto::X509Certificate& cert); /// the certificate. If shared is true, the
/// Assigns a certificate. /// certificate's reference count is incremented.
~X509Certificate(); X509Certificate(const Poco::Crypto::X509Certificate& cert);
/// Destroys the X509Certificate. /// Creates the certificate by copying another one.
long verify(const std::string& hostName) const; X509Certificate& operator = (const Poco::Crypto::X509Certificate& cert);
/// Verifies the validity of the certificate against the host name. /// Assigns a certificate.
///
/// Returns X509_V_OK if verification succeeded, or an ~X509Certificate();
/// error code (X509_V_ERR_APPLICATION_VERIFICATION) otherwise. /// Destroys the X509Certificate.
static long verify(const Poco::Crypto::X509Certificate& cert, const std::string& hostName); bool verify(const std::string& hostName) const;
/// Verifies the validity of the certificate against the host name. /// Verifies the validity of the certificate against the host name.
/// ///
/// Returns X509_V_OK if verification succeeded, or an /// For this check to be successful, the certificate must contain
/// error code (X509_V_ERR_APPLICATION_VERIFICATION) otherwise. /// a domain name that matches the domain name
/// of the host.
protected: ///
static bool containsWildcards(const std::string& commonName); /// Returns true if verification succeeded, or false otherwise.
static bool matchByAlias(const std::string& alias, const HostEntry& heData);
static bool verify(const Poco::Crypto::X509Certificate& cert, const std::string& hostName);
private: /// Verifies the validity of the certificate against the host name.
enum ///
{ /// For this check to be successful, the certificate must contain
NAME_BUFFER_SIZE = 256 /// a domain name that matches the domain name
}; /// of the host.
}; ///
/// Returns true if verification succeeded, or false otherwise.
} } // namespace Poco::Net protected:
static bool containsWildcards(const std::string& commonName);
static bool matchByAlias(const std::string& alias, const HostEntry& heData);
#endif // NetSSL_X509Certificate_INCLUDED
private:
enum
{
NAME_BUFFER_SIZE = 256
};
};
} } // namespace Poco::Net
#endif // NetSSL_X509Certificate_INCLUDED

View File

@@ -0,0 +1,302 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="debug_shared|Win32">
<Configuration>debug_shared</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_md|Win32">
<Configuration>debug_static_md</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_mt|Win32">
<Configuration>debug_static_mt</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_shared|Win32">
<Configuration>release_shared</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_md|Win32">
<Configuration>release_static_md</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_mt|Win32">
<Configuration>release_static_mt</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>HTTPSTimeServer</ProjectName>
<ProjectGuid>{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}</ProjectGuid>
<RootNamespace>HTTPSTimeServer</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">bin\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">bin\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">bin\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">bin\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">false</LinkIncremental>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">HTTPSTimeServerd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">HTTPSTimeServerd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">HTTPSTimeServerd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">HTTPSTimeServer</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">HTTPSTimeServer</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">HTTPSTimeServer</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\HTTPSTimeServerd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin\HTTPSTimeServerd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\HTTPSTimeServer.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mtd.lib;ssleay32mtd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_mt\HTTPSTimeServerd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin\static_mt\HTTPSTimeServerd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mt.lib;ssleay32mt.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_mt\HTTPSTimeServer.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_md\HTTPSTimeServerd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin\static_md\HTTPSTimeServerd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_md\HTTPSTimeServer.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="HTTPSTimeServer.properties"/>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\HTTPSTimeServer.cpp"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"/>
</Project>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Configuration Files">
<UniqueIdentifier>{a40416ad-36e4-4285-b9f5-a53af5be9463}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{1aac5164-77a5-4616-9171-444d4cd878d1}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="HTTPSTimeServer.properties">
<Filter>Configuration Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\HTTPSTimeServer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -0,0 +1,302 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="debug_shared|x64">
<Configuration>debug_shared</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_md|x64">
<Configuration>debug_static_md</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_mt|x64">
<Configuration>debug_static_mt</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_shared|x64">
<Configuration>release_shared</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_md|x64">
<Configuration>release_static_md</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_mt|x64">
<Configuration>release_static_mt</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>HTTPSTimeServer</ProjectName>
<ProjectGuid>{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}</ProjectGuid>
<RootNamespace>HTTPSTimeServer</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">bin64\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">bin64\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">bin64\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">bin64\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">false</LinkIncremental>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">HTTPSTimeServerd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">HTTPSTimeServerd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">HTTPSTimeServerd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">HTTPSTimeServer</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">HTTPSTimeServer</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">HTTPSTimeServer</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\HTTPSTimeServerd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin64\HTTPSTimeServerd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\HTTPSTimeServer.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mtd.lib;ssleay32mtd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_mt\HTTPSTimeServerd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin64\static_mt\HTTPSTimeServerd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mt.lib;ssleay32mt.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_mt\HTTPSTimeServer.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_md\HTTPSTimeServerd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin64\static_md\HTTPSTimeServerd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_md\HTTPSTimeServer.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="HTTPSTimeServer.properties"/>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\HTTPSTimeServer.cpp"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"/>
</Project>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Configuration Files">
<UniqueIdentifier>{11730e81-39a3-49ce-9a12-fc7cc81b3677}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{604b0ee0-6702-4290-903d-d49071db2abc}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="HTTPSTimeServer.properties">
<Filter>Configuration Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\HTTPSTimeServer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -1,238 +1,256 @@
// //
// TimeServer.cpp // TimeServer.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/samples/HTTPSTimeServer/src/HTTPSTimeServer.cpp#6 $ // $Id: //poco/1.4/NetSSL_OpenSSL/samples/HTTPSTimeServer/src/HTTPSTimeServer.cpp#2 $
// //
// This sample demonstrates the HTTPServer and related classes. // This sample demonstrates the HTTPServer and related classes.
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/HTTPServer.h" #include "Poco/Net/HTTPServer.h"
#include "Poco/Net/HTTPRequestHandler.h" #include "Poco/Net/HTTPRequestHandler.h"
#include "Poco/Net/HTTPRequestHandlerFactory.h" #include "Poco/Net/HTTPRequestHandlerFactory.h"
#include "Poco/Net/HTTPServerParams.h" #include "Poco/Net/HTTPServerParams.h"
#include "Poco/Net/HTTPServerRequest.h" #include "Poco/Net/HTTPServerRequestImpl.h"
#include "Poco/Net/HTTPServerResponse.h" #include "Poco/Net/HTTPServerResponse.h"
#include "Poco/Net/HTTPServerParams.h" #include "Poco/Net/HTTPServerParams.h"
#include "Poco/Net/SecureServerSocket.h" #include "Poco/Net/SecureStreamSocket.h"
#include "Poco/Timestamp.h" #include "Poco/Net/SecureServerSocket.h"
#include "Poco/DateTimeFormatter.h" #include "Poco/Net/X509Certificate.h"
#include "Poco/DateTimeFormat.h" #include "Poco/Timestamp.h"
#include "Poco/Exception.h" #include "Poco/DateTimeFormatter.h"
#include "Poco/SharedPtr.h" #include "Poco/DateTimeFormat.h"
#include "Poco/Util/ServerApplication.h" #include "Poco/Exception.h"
#include "Poco/Util/Option.h" #include "Poco/SharedPtr.h"
#include "Poco/Util/OptionSet.h" #include "Poco/Util/ServerApplication.h"
#include "Poco/Util/HelpFormatter.h" #include "Poco/Util/Option.h"
#include "Poco/Net/SSLManager.h" #include "Poco/Util/OptionSet.h"
#include "Poco/Net/KeyConsoleHandler.h" #include "Poco/Util/HelpFormatter.h"
#include "Poco/Net/AcceptCertificateHandler.h" #include "Poco/Net/SSLManager.h"
#include <iostream> #include "Poco/Net/KeyConsoleHandler.h"
#include "Poco/Net/AcceptCertificateHandler.h"
#include <iostream>
using Poco::Net::SecureServerSocket;
using Poco::Net::HTTPRequestHandler;
using Poco::Net::HTTPRequestHandlerFactory; using Poco::Net::SecureServerSocket;
using Poco::Net::HTTPServer; using Poco::Net::SecureStreamSocket;
using Poco::Net::HTTPServerRequest; using Poco::Net::HTTPRequestHandler;
using Poco::Net::HTTPServerResponse; using Poco::Net::HTTPRequestHandlerFactory;
using Poco::Net::HTTPServerParams; using Poco::Net::HTTPServer;
using Poco::Timestamp; using Poco::Net::HTTPServerRequest;
using Poco::DateTimeFormatter; using Poco::Net::HTTPServerRequestImpl;
using Poco::DateTimeFormat; using Poco::Net::X509Certificate;
using Poco::SharedPtr; using Poco::Net::HTTPServerResponse;
using Poco::Util::ServerApplication; using Poco::Net::HTTPServerParams;
using Poco::Util::Application; using Poco::Timestamp;
using Poco::Util::Option; using Poco::DateTimeFormatter;
using Poco::Util::OptionSet; using Poco::DateTimeFormat;
using Poco::Util::HelpFormatter; using Poco::SharedPtr;
using Poco::Net::SSLManager; using Poco::Util::ServerApplication;
using Poco::Net::Context; using Poco::Util::Application;
using Poco::Net::KeyConsoleHandler; using Poco::Util::Option;
using Poco::Net::PrivateKeyPassphraseHandler; using Poco::Util::OptionSet;
using Poco::Net::InvalidCertificateHandler; using Poco::Util::HelpFormatter;
using Poco::Net::AcceptCertificateHandler; using Poco::Net::SSLManager;
using Poco::Net::Context;
using Poco::Net::KeyConsoleHandler;
class TimeRequestHandler: public HTTPRequestHandler using Poco::Net::PrivateKeyPassphraseHandler;
/// Return a HTML document with the current date and time. using Poco::Net::InvalidCertificateHandler;
{ using Poco::Net::AcceptCertificateHandler;
public:
TimeRequestHandler(const std::string& format):
_format(format) class TimeRequestHandler: public HTTPRequestHandler
{ /// Return a HTML document with the current date and time.
} {
public:
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) TimeRequestHandler(const std::string& format):
{ _format(format)
Application& app = Application::instance(); {
app.logger().information("Request from " + request.clientAddress().toString()); }
Timestamp now; void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
std::string dt(DateTimeFormatter::format(now, _format)); {
Application& app = Application::instance();
response.setChunkedTransferEncoding(true); app.logger().information("Request from " + request.clientAddress().toString());
response.setContentType("text/html");
SecureStreamSocket socket = static_cast<HTTPServerRequestImpl&>(request).socket();
std::ostream& ostr = response.send(); if (socket.havePeerCertificate())
ostr << "<html><head><title>HTTPTimeServer powered by POCO C++ Libraries</title>"; {
ostr << "<meta http-equiv=\"refresh\" content=\"1\"></head>"; X509Certificate cert = socket.peerCertificate();
ostr << "<body><p style=\"text-align: center; font-size: 48px;\">"; app.logger().information("Client certificate: " + cert.subjectName());
ostr << dt; }
ostr << "</p></body></html>"; else
} {
app.logger().information("No client certificate available.");
private: }
std::string _format;
}; Timestamp now;
std::string dt(DateTimeFormatter::format(now, _format));
class TimeRequestHandlerFactory: public HTTPRequestHandlerFactory response.setChunkedTransferEncoding(true);
{ response.setContentType("text/html");
public:
TimeRequestHandlerFactory(const std::string& format): std::ostream& ostr = response.send();
_format(format) ostr << "<html><head><title>HTTPTimeServer powered by POCO C++ Libraries</title>";
{ ostr << "<meta http-equiv=\"refresh\" content=\"1\"></head>";
} ostr << "<body><p style=\"text-align: center; font-size: 48px;\">";
ostr << dt;
HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request) ostr << "</p></body></html>";
{ }
if (request.getURI() == "/")
return new TimeRequestHandler(_format); private:
else std::string _format;
return 0; };
}
private: class TimeRequestHandlerFactory: public HTTPRequestHandlerFactory
std::string _format; {
}; public:
TimeRequestHandlerFactory(const std::string& format):
_format(format)
class HTTPSTimeServer: public Poco::Util::ServerApplication {
/// The main application class. }
///
/// This class handles command-line arguments and HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request)
/// configuration files. {
/// Start the HTTPTimeServer executable with the help if (request.getURI() == "/")
/// option (/help on Windows, --help on Unix) for return new TimeRequestHandler(_format);
/// the available command line options. else
/// return 0;
/// To use the sample configuration file (HTTPTimeServer.properties), }
/// copy the file to the directory where the HTTPTimeServer executable
/// resides. If you start the debug version of the HTTPTimeServer private:
/// (HTTPTimeServerd[.exe]), you must also create a copy of the configuration std::string _format;
/// file named HTTPTimeServerd.properties. In the configuration file, you };
/// can specify the port on which the server is listening (default
/// 9980) and the format of the date/time string sent back to the client.
/// class HTTPSTimeServer: public Poco::Util::ServerApplication
/// To test the TimeServer you can use any web browser (https://localhost:9980/). /// The main application class.
{ ///
public: /// This class handles command-line arguments and
HTTPSTimeServer(): _helpRequested(false) /// configuration files.
{ /// Start the HTTPTimeServer executable with the help
} /// option (/help on Windows, --help on Unix) for
/// the available command line options.
~HTTPSTimeServer() ///
{ /// To use the sample configuration file (HTTPTimeServer.properties),
} /// copy the file to the directory where the HTTPTimeServer executable
/// resides. If you start the debug version of the HTTPTimeServer
protected: /// (HTTPTimeServerd[.exe]), you must also create a copy of the configuration
void initialize(Application& self) /// file named HTTPTimeServerd.properties. In the configuration file, you
{ /// can specify the port on which the server is listening (default
loadConfiguration(); // load default configuration files, if present /// 9443) and the format of the date/time string sent back to the client.
ServerApplication::initialize(self); ///
} /// To test the TimeServer you can use any web browser (https://localhost:9443/).
{
void uninitialize() public:
{ HTTPSTimeServer(): _helpRequested(false)
ServerApplication::uninitialize(); {
} Poco::Net::initializeSSL();
}
void defineOptions(OptionSet& options)
{ ~HTTPSTimeServer()
ServerApplication::defineOptions(options); {
Poco::Net::uninitializeSSL();
options.addOption( }
Option("help", "h", "display help information on command line arguments")
.required(false) protected:
.repeatable(false)); void initialize(Application& self)
} {
loadConfiguration(); // load default configuration files, if present
void handleOption(const std::string& name, const std::string& value) ServerApplication::initialize(self);
{ }
ServerApplication::handleOption(name, value);
void uninitialize()
if (name == "help") {
_helpRequested = true; ServerApplication::uninitialize();
} }
void displayHelp() void defineOptions(OptionSet& options)
{ {
HelpFormatter helpFormatter(options()); ServerApplication::defineOptions(options);
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS"); options.addOption(
helpFormatter.setHeader("A web server that serves the current date and time."); Option("help", "h", "display help information on command line arguments")
helpFormatter.format(std::cout); .required(false)
} .repeatable(false));
}
int main(const std::vector<std::string>& args)
{ void handleOption(const std::string& name, const std::string& value)
if (_helpRequested) {
{ ServerApplication::handleOption(name, value);
displayHelp();
} if (name == "help")
else _helpRequested = true;
{ }
// get parameters from configuration file
unsigned short port = (unsigned short) config().getInt("HTTPTimeServer.port", 9980); void displayHelp()
std::string format(config().getString("HTTPTimeServer.format", DateTimeFormat::SORTABLE_FORMAT)); {
HelpFormatter helpFormatter(options());
// set-up a server socket helpFormatter.setCommand(commandName());
SecureServerSocket svs(port); helpFormatter.setUsage("OPTIONS");
// set-up a HTTPServer instance helpFormatter.setHeader("A web server that serves the current date and time.");
HTTPServer srv(new TimeRequestHandlerFactory(format), svs, new HTTPServerParams); helpFormatter.format(std::cout);
// start the HTTPServer }
srv.start();
// wait for CTRL-C or kill int main(const std::vector<std::string>& args)
waitForTerminationRequest(); {
// Stop the HTTPServer if (_helpRequested)
srv.stop(); {
} displayHelp();
return Application::EXIT_OK; }
} else
{
private: // get parameters from configuration file
bool _helpRequested; unsigned short port = (unsigned short) config().getInt("HTTPSTimeServer.port", 9443);
}; std::string format(config().getString("HTTPSTimeServer.format", DateTimeFormat::SORTABLE_FORMAT));
// set-up a server socket
int main(int argc, char** argv) SecureServerSocket svs(port);
{ // set-up a HTTPServer instance
HTTPSTimeServer app; HTTPServer srv(new TimeRequestHandlerFactory(format), svs, new HTTPServerParams);
return app.run(argc, argv); // start the HTTPServer
} srv.start();
// wait for CTRL-C or kill
waitForTerminationRequest();
// Stop the HTTPServer
srv.stop();
}
return Application::EXIT_OK;
}
private:
bool _helpRequested;
};
int main(int argc, char** argv)
{
HTTPSTimeServer app;
return app.run(argc, argv);
}

View File

@@ -0,0 +1,299 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="debug_shared|Win32">
<Configuration>debug_shared</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_md|Win32">
<Configuration>debug_static_md</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_mt|Win32">
<Configuration>debug_static_mt</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_shared|Win32">
<Configuration>release_shared</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_md|Win32">
<Configuration>release_static_md</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_mt|Win32">
<Configuration>release_static_mt</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>download</ProjectName>
<ProjectGuid>{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}</ProjectGuid>
<RootNamespace>download</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">bin\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">bin\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">bin\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">bin\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">false</LinkIncremental>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">downloadd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">downloadd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">downloadd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">download</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">download</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">download</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\downloadd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin\downloadd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\download.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mtd.lib;ssleay32mtd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_mt\downloadd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin\static_mt\downloadd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mt.lib;ssleay32mt.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_mt\download.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_md\downloadd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin\static_md\downloadd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_md\download.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\download.cpp"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"/>
</Project>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{d0347c7d-3fbe-4ac8-a7b0-b96f698bda52}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\download.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -0,0 +1,299 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="debug_shared|x64">
<Configuration>debug_shared</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_md|x64">
<Configuration>debug_static_md</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_mt|x64">
<Configuration>debug_static_mt</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_shared|x64">
<Configuration>release_shared</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_md|x64">
<Configuration>release_static_md</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_mt|x64">
<Configuration>release_static_mt</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>download</ProjectName>
<ProjectGuid>{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}</ProjectGuid>
<RootNamespace>download</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">bin64\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">bin64\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">bin64\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">bin64\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">false</LinkIncremental>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">downloadd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">downloadd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">downloadd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">download</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">download</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">download</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\downloadd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin64\downloadd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\download.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mtd.lib;ssleay32mtd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_mt\downloadd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin64\static_mt\downloadd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mt.lib;ssleay32mt.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_mt\download.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_md\downloadd.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin64\static_md\downloadd.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include;..\..\..\NetSSL_OpenSSL\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_md\download.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\download.cpp"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"/>
</Project>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{dbd8c9fd-9fa3-498c-bf1c-cbbc9afe03e3}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\download.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -1,101 +1,117 @@
// //
// download.cpp // download.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/samples/download/src/download.cpp#8 $ // $Id: //poco/Main/NetSSL_OpenSSL/samples/download/src/download.cpp#8 $
// //
// This sample demonstrates the URIStreamOpener class. // This sample demonstrates the URIStreamOpener class.
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/URIStreamOpener.h" #include "Poco/URIStreamOpener.h"
#include "Poco/StreamCopier.h" #include "Poco/StreamCopier.h"
#include "Poco/Path.h" #include "Poco/Path.h"
#include "Poco/URI.h" #include "Poco/URI.h"
#include "Poco/SharedPtr.h" #include "Poco/SharedPtr.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/Net/HTTPStreamFactory.h" #include "Poco/Net/HTTPStreamFactory.h"
#include "Poco/Net/HTTPSStreamFactory.h" #include "Poco/Net/HTTPSStreamFactory.h"
#include "Poco/Net/FTPStreamFactory.h" #include "Poco/Net/FTPStreamFactory.h"
#include "Poco/Net/SSLManager.h" #include "Poco/Net/SSLManager.h"
#include "Poco/Net/KeyConsoleHandler.h" #include "Poco/Net/KeyConsoleHandler.h"
#include "Poco/Net/ConsoleCertificateHandler.h" #include "Poco/Net/ConsoleCertificateHandler.h"
#include <memory> #include <memory>
#include <iostream> #include <iostream>
using Poco::URIStreamOpener; using Poco::URIStreamOpener;
using Poco::StreamCopier; using Poco::StreamCopier;
using Poco::Path; using Poco::Path;
using Poco::URI; using Poco::URI;
using Poco::SharedPtr; using Poco::SharedPtr;
using Poco::Exception; using Poco::Exception;
using Poco::Net::HTTPStreamFactory; using Poco::Net::HTTPStreamFactory;
using Poco::Net::HTTPSStreamFactory; using Poco::Net::HTTPSStreamFactory;
using Poco::Net::FTPStreamFactory; using Poco::Net::FTPStreamFactory;
using Poco::Net::SSLManager; using Poco::Net::SSLManager;
using Poco::Net::Context; using Poco::Net::Context;
using Poco::Net::KeyConsoleHandler; using Poco::Net::KeyConsoleHandler;
using Poco::Net::PrivateKeyPassphraseHandler; using Poco::Net::PrivateKeyPassphraseHandler;
using Poco::Net::InvalidCertificateHandler; using Poco::Net::InvalidCertificateHandler;
using Poco::Net::ConsoleCertificateHandler; using Poco::Net::ConsoleCertificateHandler;
int main(int argc, char** argv) class SSLInitializer
{ {
HTTPStreamFactory::registerFactory(); public:
HTTPSStreamFactory::registerFactory(); SSLInitializer()
FTPStreamFactory::registerFactory(); {
Poco::Net::initializeSSL();
if (argc != 2) }
{
Path p(argv[0]); ~SSLInitializer()
std::cerr << "usage: " << p.getBaseName() << " <uri>" << std::endl; {
std::cerr << " Download <uri> to standard output." << std::endl; Poco::Net::uninitializeSSL();
std::cerr << " Works with http, https, ftp and file URIs." << std::endl; }
return 1; };
}
// Note: we must create the passphrase handler prior Context int main(int argc, char** argv)
SharedPtr<InvalidCertificateHandler> ptrCert = new ConsoleCertificateHandler(false); // ask the user via console {
Context::Ptr ptrContext = new Context(Context::CLIENT_USE, "", "", "rootcert.pem", Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); SSLInitializer sslInitializer;
SSLManager::instance().initializeClient(0, ptrCert, ptrContext); HTTPStreamFactory::registerFactory();
HTTPSStreamFactory::registerFactory();
try FTPStreamFactory::registerFactory();
{
URI uri(argv[1]); if (argc != 2)
std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri)); {
StreamCopier::copyStream(*pStr.get(), std::cout); Path p(argv[0]);
} std::cerr << "usage: " << p.getBaseName() << " <uri>" << std::endl;
catch (Exception& exc) std::cerr << " Download <uri> to standard output." << std::endl;
{ std::cerr << " Works with http, https, ftp and file URIs." << std::endl;
std::cerr << exc.displayText() << std::endl; return 1;
return 1; }
}
// Note: we must create the passphrase handler prior Context
return 0; SharedPtr<InvalidCertificateHandler> ptrCert = new ConsoleCertificateHandler(false); // ask the user via console
} Context::Ptr ptrContext = new Context(Context::CLIENT_USE, "", "", "rootcert.pem", Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
SSLManager::instance().initializeClient(0, ptrCert, ptrContext);
try
{
URI uri(argv[1]);
std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
StreamCopier::copyStream(*pStr.get(), std::cout);
}
catch (Exception& exc)
{
std::cerr << exc.displayText() << std::endl;
return 1;
}
return 0;
}

View File

@@ -0,0 +1,57 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "download", "download\download_vs100.vcxproj", "{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPSTimeServer", "HTTPSTimeServer\HTTPSTimeServer_vs100.vcxproj", "{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug_shared|Win32 = debug_shared|Win32
release_shared|Win32 = release_shared|Win32
debug_static_mt|Win32 = debug_static_mt|Win32
release_static_mt|Win32 = release_static_mt|Win32
debug_static_md|Win32 = debug_static_md|Win32
release_static_md|Win32 = release_static_md|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_shared|Win32.Build.0 = debug_shared|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_shared|Win32.Deploy.0 = debug_shared|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_shared|Win32.ActiveCfg = release_shared|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_shared|Win32.Build.0 = release_shared|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_shared|Win32.Deploy.0 = release_shared|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_md|Win32.Deploy.0 = debug_static_md|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_md|Win32.Build.0 = release_static_md|Win32
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_md|Win32.Deploy.0 = release_static_md|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_shared|Win32.Build.0 = debug_shared|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_shared|Win32.Deploy.0 = debug_shared|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_shared|Win32.ActiveCfg = release_shared|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_shared|Win32.Build.0 = release_shared|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_shared|Win32.Deploy.0 = release_shared|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_md|Win32.Deploy.0 = debug_static_md|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_md|Win32.Build.0 = release_static_md|Win32
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_md|Win32.Deploy.0 = release_static_md|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,57 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "download", "download\download_x64_vs100.vcxproj", "{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPSTimeServer", "HTTPSTimeServer\HTTPSTimeServer_x64_vs100.vcxproj", "{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug_shared|x64 = debug_shared|x64
release_shared|x64 = release_shared|x64
debug_static_mt|x64 = debug_static_mt|x64
release_static_mt|x64 = release_static_mt|x64
debug_static_md|x64 = debug_static_md|x64
release_static_md|x64 = release_static_md|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_shared|x64.ActiveCfg = debug_shared|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_shared|x64.Build.0 = debug_shared|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_shared|x64.Deploy.0 = debug_shared|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_shared|x64.ActiveCfg = release_shared|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_shared|x64.Build.0 = release_shared|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_shared|x64.Deploy.0 = release_shared|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_mt|x64.ActiveCfg = debug_static_mt|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_mt|x64.Build.0 = debug_static_mt|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_mt|x64.Deploy.0 = debug_static_mt|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_mt|x64.ActiveCfg = release_static_mt|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_mt|x64.Build.0 = release_static_mt|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_mt|x64.Deploy.0 = release_static_mt|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_md|x64.ActiveCfg = debug_static_md|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_md|x64.Build.0 = debug_static_md|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.debug_static_md|x64.Deploy.0 = debug_static_md|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_md|x64.ActiveCfg = release_static_md|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_md|x64.Build.0 = release_static_md|x64
{D853F3D6-0D6F-3E8E-82C7-4216D7A21C4D}.release_static_md|x64.Deploy.0 = release_static_md|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_shared|x64.ActiveCfg = debug_shared|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_shared|x64.Build.0 = debug_shared|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_shared|x64.Deploy.0 = debug_shared|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_shared|x64.ActiveCfg = release_shared|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_shared|x64.Build.0 = release_shared|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_shared|x64.Deploy.0 = release_shared|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_mt|x64.ActiveCfg = debug_static_mt|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_mt|x64.Build.0 = debug_static_mt|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_mt|x64.Deploy.0 = debug_static_mt|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_mt|x64.ActiveCfg = release_static_mt|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_mt|x64.Build.0 = release_static_mt|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_mt|x64.Deploy.0 = release_static_mt|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_md|x64.ActiveCfg = debug_static_md|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_md|x64.Build.0 = debug_static_md|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.debug_static_md|x64.Deploy.0 = debug_static_md|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_md|x64.ActiveCfg = release_static_md|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_md|x64.Build.0 = release_static_md|x64
{F8DE5054-3EC1-3FB4-9FE6-38EE974745A9}.release_static_md|x64.Deploy.0 = release_static_md|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,90 +1,91 @@
// //
// CertificateHandlerFactoryMgr.cpp // CertificateHandlerFactoryMgr.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/CertificateHandlerFactoryMgr.cpp#10 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/CertificateHandlerFactoryMgr.cpp#10 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: CertificateHandlerFactoryMgr // Module: CertificateHandlerFactoryMgr
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/CertificateHandlerFactoryMgr.h" #include "Poco/Net/CertificateHandlerFactoryMgr.h"
#include "Poco/Net/ConsoleCertificateHandler.h" #include "Poco/Net/ConsoleCertificateHandler.h"
#include "Poco/Net/AcceptCertificateHandler.h" #include "Poco/Net/AcceptCertificateHandler.h"
#include "Poco/Net/RejectCertificateHandler.h"
namespace Poco {
namespace Net { namespace Poco {
namespace Net {
CertificateHandlerFactoryMgr::CertificateHandlerFactoryMgr()
{ CertificateHandlerFactoryMgr::CertificateHandlerFactoryMgr()
setFactory("ConsoleCertificateHandler", new CertificateHandlerFactoryImpl<ConsoleCertificateHandler>()); {
setFactory("AcceptCertificateHandler", new CertificateHandlerFactoryImpl<AcceptCertificateHandler>()); setFactory("ConsoleCertificateHandler", new CertificateHandlerFactoryImpl<ConsoleCertificateHandler>());
setFactory("AcceptCertificateHandler", new CertificateHandlerFactoryImpl<AcceptCertificateHandler>());
} setFactory("RejectCertificateHandler", new CertificateHandlerFactoryImpl<RejectCertificateHandler>());
}
CertificateHandlerFactoryMgr::~CertificateHandlerFactoryMgr()
{ CertificateHandlerFactoryMgr::~CertificateHandlerFactoryMgr()
} {
}
void CertificateHandlerFactoryMgr::setFactory(const std::string& name, CertificateHandlerFactory* pFactory)
{ void CertificateHandlerFactoryMgr::setFactory(const std::string& name, CertificateHandlerFactory* pFactory)
bool success = _factories.insert(make_pair(name, Poco::SharedPtr<CertificateHandlerFactory>(pFactory))).second; {
if (!success) bool success = _factories.insert(make_pair(name, Poco::SharedPtr<CertificateHandlerFactory>(pFactory))).second;
delete pFactory; if (!success)
poco_assert(success); delete pFactory;
} poco_assert(success);
}
bool CertificateHandlerFactoryMgr::hasFactory(const std::string& name) const
{ bool CertificateHandlerFactoryMgr::hasFactory(const std::string& name) const
return _factories.find(name) != _factories.end(); {
} return _factories.find(name) != _factories.end();
}
const CertificateHandlerFactory* CertificateHandlerFactoryMgr::getFactory(const std::string& name) const
{ const CertificateHandlerFactory* CertificateHandlerFactoryMgr::getFactory(const std::string& name) const
FactoriesMap::const_iterator it = _factories.find(name); {
if (it != _factories.end()) FactoriesMap::const_iterator it = _factories.find(name);
return it->second; if (it != _factories.end())
else return it->second;
return 0; else
} return 0;
}
void CertificateHandlerFactoryMgr::removeFactory(const std::string& name)
{ void CertificateHandlerFactoryMgr::removeFactory(const std::string& name)
_factories.erase(name); {
} _factories.erase(name);
}
} } // namespace Poco::Net
} } // namespace Poco::Net

View File

@@ -1,139 +1,354 @@
// //
// Context.cpp // Context.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/Context.cpp#18 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/Context.cpp#18 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: Context // Module: Context
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/Context.h" #include "Poco/Net/Context.h"
#include "Poco/Net/SSLManager.h" #include "Poco/Net/SSLManager.h"
#include "Poco/Net/SSLException.h" #include "Poco/Net/SSLException.h"
#include "Poco/Net/Utility.h" #include "Poco/Net/Utility.h"
#include "Poco/File.h" #include "Poco/Crypto/OpenSSLInitializer.h"
#include <openssl/bio.h> #include "Poco/File.h"
#include <openssl/err.h> #include "Poco/Path.h"
#include <openssl/ssl.h> #include "Poco/Timestamp.h"
#include <openssl/x509v3.h> #include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
namespace Poco { #include <openssl/x509v3.h>
namespace Net {
namespace Poco {
Context::Context( namespace Net {
Usage usage,
const std::string& privateKeyFile,
const std::string& certificateFile, Context::Context(
const std::string& caLocation, Usage usage,
VerificationMode verificationMode, const std::string& privateKeyFile,
int verificationDepth, const std::string& certificateFile,
bool loadDefaultCAs, const std::string& caLocation,
const std::string& cypherList): VerificationMode verificationMode,
_usage(usage), int verificationDepth,
_mode(verificationMode), bool loadDefaultCAs,
_pSSLContext(0) const std::string& cipherList):
{ _usage(usage),
_pSSLContext = SSL_CTX_new(SSLv23_method()); _mode(verificationMode),
if (!_pSSLContext) _pSSLContext(0),
{ _extendedCertificateVerification(true)
unsigned long err = ERR_get_error(); {
throw SSLException("Cannot create SSL_CTX object", ERR_error_string(err, 0)); Poco::Crypto::OpenSSLInitializer::initialize();
}
SSL_CTX_set_default_passwd_cb(_pSSLContext, &SSLManager::privateKeyPasswdCallback); if (SSLManager::isFIPSEnabled())
Utility::clearErrorStack(); {
_pSSLContext = SSL_CTX_new(TLSv1_method());
int errCode = 0; }
if (!caLocation.empty()) else
{ {
Poco::File aFile(caLocation); _pSSLContext = SSL_CTX_new(SSLv23_method());
if (aFile.isDirectory()) }
errCode = SSL_CTX_load_verify_locations(_pSSLContext, 0, caLocation.c_str()); if (!_pSSLContext)
else {
errCode = SSL_CTX_load_verify_locations(_pSSLContext, caLocation.c_str(), 0); unsigned long err = ERR_get_error();
if (errCode != 1) throw SSLException("Cannot create SSL_CTX object", ERR_error_string(err, 0));
{ }
std::string msg = Utility::getLastError(); SSL_CTX_set_default_passwd_cb(_pSSLContext, &SSLManager::privateKeyPassphraseCallback);
SSL_CTX_free(_pSSLContext); Utility::clearErrorStack();
throw SSLContextException(std::string("Cannot load CA file/directory at ") + caLocation, msg); SSL_CTX_set_options(_pSSLContext, SSL_OP_ALL);
}
} int errCode = 0;
if (!caLocation.empty())
if (loadDefaultCAs) {
{ Poco::File aFile(caLocation);
errCode = SSL_CTX_set_default_verify_paths(_pSSLContext); if (aFile.isDirectory())
if (errCode != 1) errCode = SSL_CTX_load_verify_locations(_pSSLContext, 0, Poco::Path::transcode(caLocation).c_str());
{ else
std::string msg = Utility::getLastError(); errCode = SSL_CTX_load_verify_locations(_pSSLContext, Poco::Path::transcode(caLocation).c_str(), 0);
SSL_CTX_free(_pSSLContext); if (errCode != 1)
throw SSLContextException("Cannot load default CA certificates", msg); {
} std::string msg = Utility::getLastError();
} SSL_CTX_free(_pSSLContext);
throw SSLContextException(std::string("Cannot load CA file/directory at ") + caLocation, msg);
if (!privateKeyFile.empty()) }
{ }
errCode = SSL_CTX_use_PrivateKey_file(_pSSLContext, privateKeyFile.c_str(), SSL_FILETYPE_PEM);
if (errCode != 1) if (loadDefaultCAs)
{ {
std::string msg = Utility::getLastError(); errCode = SSL_CTX_set_default_verify_paths(_pSSLContext);
SSL_CTX_free(_pSSLContext); if (errCode != 1)
throw SSLContextException(std::string("Error loading private key from file ") + privateKeyFile, msg); {
} std::string msg = Utility::getLastError();
} SSL_CTX_free(_pSSLContext);
throw SSLContextException("Cannot load default CA certificates", msg);
if (!certificateFile.empty()) }
{ }
errCode = SSL_CTX_use_certificate_chain_file(_pSSLContext, certificateFile.c_str());
if (errCode != 1) if (!privateKeyFile.empty())
{ {
std::string errMsg = Utility::getLastError(); errCode = SSL_CTX_use_PrivateKey_file(_pSSLContext, Poco::Path::transcode(privateKeyFile).c_str(), SSL_FILETYPE_PEM);
SSL_CTX_free(_pSSLContext); if (errCode != 1)
throw SSLContextException(std::string("Error loading certificate from file ") + privateKeyFile, errMsg); {
} std::string msg = Utility::getLastError();
} SSL_CTX_free(_pSSLContext);
throw SSLContextException(std::string("Error loading private key from file ") + privateKeyFile, msg);
if (usage == SERVER_USE) }
SSL_CTX_set_verify(_pSSLContext, verificationMode, &SSLManager::verifyServerCallback); }
else
SSL_CTX_set_verify(_pSSLContext, verificationMode, &SSLManager::verifyClientCallback); if (!certificateFile.empty())
{
SSL_CTX_set_verify_depth(_pSSLContext, verificationDepth); errCode = SSL_CTX_use_certificate_chain_file(_pSSLContext, Poco::Path::transcode(certificateFile).c_str());
SSL_CTX_set_mode(_pSSLContext, SSL_MODE_AUTO_RETRY); if (errCode != 1)
} {
std::string errMsg = Utility::getLastError();
SSL_CTX_free(_pSSLContext);
Context::~Context() throw SSLContextException(std::string("Error loading certificate from file ") + certificateFile, errMsg);
{ }
SSL_CTX_free(_pSSLContext); }
}
if (usage == SERVER_USE)
SSL_CTX_set_verify(_pSSLContext, verificationMode, &SSLManager::verifyServerCallback);
} } // namespace Poco::Net else
SSL_CTX_set_verify(_pSSLContext, verificationMode, &SSLManager::verifyClientCallback);
SSL_CTX_set_cipher_list(_pSSLContext, cipherList.c_str());
SSL_CTX_set_verify_depth(_pSSLContext, verificationDepth);
SSL_CTX_set_mode(_pSSLContext, SSL_MODE_AUTO_RETRY);
SSL_CTX_set_session_cache_mode(_pSSLContext, SSL_SESS_CACHE_OFF);
}
Context::Context(
Usage usage,
const std::string& caLocation,
VerificationMode verificationMode,
int verificationDepth,
bool loadDefaultCAs,
const std::string& cipherList):
_usage(usage),
_mode(verificationMode),
_pSSLContext(0),
_extendedCertificateVerification(true)
{
Poco::Crypto::OpenSSLInitializer::initialize();
if (SSLManager::isFIPSEnabled())
{
_pSSLContext = SSL_CTX_new(TLSv1_method());
}
else
{
_pSSLContext = SSL_CTX_new(SSLv23_method());
}
if (!_pSSLContext)
{
unsigned long err = ERR_get_error();
throw SSLException("Cannot create SSL_CTX object", ERR_error_string(err, 0));
}
SSL_CTX_set_default_passwd_cb(_pSSLContext, &SSLManager::privateKeyPassphraseCallback);
Utility::clearErrorStack();
SSL_CTX_set_options(_pSSLContext, SSL_OP_ALL);
int errCode = 0;
if (!caLocation.empty())
{
Poco::File aFile(caLocation);
if (aFile.isDirectory())
errCode = SSL_CTX_load_verify_locations(_pSSLContext, 0, Poco::Path::transcode(caLocation).c_str());
else
errCode = SSL_CTX_load_verify_locations(_pSSLContext, Poco::Path::transcode(caLocation).c_str(), 0);
if (errCode != 1)
{
std::string msg = Utility::getLastError();
SSL_CTX_free(_pSSLContext);
throw SSLContextException(std::string("Cannot load CA file/directory at ") + caLocation, msg);
}
}
if (loadDefaultCAs)
{
errCode = SSL_CTX_set_default_verify_paths(_pSSLContext);
if (errCode != 1)
{
std::string msg = Utility::getLastError();
SSL_CTX_free(_pSSLContext);
throw SSLContextException("Cannot load default CA certificates", msg);
}
}
if (usage == SERVER_USE)
SSL_CTX_set_verify(_pSSLContext, verificationMode, &SSLManager::verifyServerCallback);
else
SSL_CTX_set_verify(_pSSLContext, verificationMode, &SSLManager::verifyClientCallback);
SSL_CTX_set_cipher_list(_pSSLContext, cipherList.c_str());
SSL_CTX_set_verify_depth(_pSSLContext, verificationDepth);
SSL_CTX_set_mode(_pSSLContext, SSL_MODE_AUTO_RETRY);
SSL_CTX_set_session_cache_mode(_pSSLContext, SSL_SESS_CACHE_OFF);
}
Context::~Context()
{
SSL_CTX_free(_pSSLContext);
Poco::Crypto::OpenSSLInitializer::uninitialize();
}
void Context::useCertificate(const Poco::Crypto::X509Certificate& certificate)
{
int errCode = SSL_CTX_use_certificate(_pSSLContext, const_cast<X509*>(certificate.certificate()));
if (errCode != 1)
{
std::string msg = Utility::getLastError();
throw SSLContextException("Cannot set certificate for Context", msg);
}
}
void Context::addChainCertificate(const Poco::Crypto::X509Certificate& certificate)
{
int errCode = SSL_CTX_add_extra_chain_cert(_pSSLContext, certificate.certificate());
if (errCode != 1)
{
std::string msg = Utility::getLastError();
throw SSLContextException("Cannot add chain certificate to Context", msg);
}
}
void Context::usePrivateKey(const Poco::Crypto::RSAKey& key)
{
int errCode = SSL_CTX_use_RSAPrivateKey(_pSSLContext, key.impl()->getRSA());
if (errCode != 1)
{
std::string msg = Utility::getLastError();
throw SSLContextException("Cannot set private key for Context", msg);
}
}
void Context::enableSessionCache(bool flag)
{
if (flag)
{
SSL_CTX_set_session_cache_mode(_pSSLContext, _usage == SERVER_USE ? SSL_SESS_CACHE_SERVER : SSL_SESS_CACHE_CLIENT);
}
else
{
SSL_CTX_set_session_cache_mode(_pSSLContext, SSL_SESS_CACHE_OFF);
}
}
void Context::enableSessionCache(bool flag, const std::string& sessionIdContext)
{
poco_assert (_usage == SERVER_USE);
if (flag)
{
SSL_CTX_set_session_cache_mode(_pSSLContext, SSL_SESS_CACHE_SERVER);
}
else
{
SSL_CTX_set_session_cache_mode(_pSSLContext, SSL_SESS_CACHE_OFF);
}
unsigned length = static_cast<unsigned>(sessionIdContext.length());
if (length > SSL_MAX_SSL_SESSION_ID_LENGTH) length = SSL_MAX_SSL_SESSION_ID_LENGTH;
int rc = SSL_CTX_set_session_id_context(_pSSLContext, reinterpret_cast<const unsigned char*>(sessionIdContext.data()), length);
if (rc != 1) throw SSLContextException("cannot set session ID context");
}
bool Context::sessionCacheEnabled() const
{
return SSL_CTX_get_session_cache_mode(_pSSLContext) != SSL_SESS_CACHE_OFF;
}
void Context::setSessionCacheSize(std::size_t size)
{
poco_assert (_usage == SERVER_USE);
SSL_CTX_sess_set_cache_size(_pSSLContext, static_cast<long>(size));
}
std::size_t Context::getSessionCacheSize() const
{
poco_assert (_usage == SERVER_USE);
return static_cast<std::size_t>(SSL_CTX_sess_get_cache_size(_pSSLContext));
}
void Context::setSessionTimeout(long seconds)
{
poco_assert (_usage == SERVER_USE);
SSL_CTX_set_timeout(_pSSLContext, seconds);
}
long Context::getSessionTimeout() const
{
poco_assert (_usage == SERVER_USE);
return SSL_CTX_get_timeout(_pSSLContext);
}
void Context::flushSessionCache()
{
poco_assert (_usage == SERVER_USE);
Poco::Timestamp now;
SSL_CTX_flush_sessions(_pSSLContext, static_cast<long>(now.epochTime()));
}
void Context::enableExtendedCertificateVerification(bool flag)
{
_extendedCertificateVerification = flag;
}
void Context::disableStatelessSessionResumption()
{
#if defined(SSL_OP_NO_TICKET)
SSL_CTX_set_options(_pSSLContext, SSL_OP_NO_TICKET);
#endif
}
} } // namespace Poco::Net

View File

@@ -1,147 +1,215 @@
// //
// HTTPSClientSession.cpp // HTTPSClientSession.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/HTTPSClientSession.cpp#13 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/HTTPSClientSession.cpp#13 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: HTTPSClient // Package: HTTPSClient
// Module: HTTPSClientSession // Module: HTTPSClientSession
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/HTTPSClientSession.h" #include "Poco/Net/HTTPSClientSession.h"
#include "Poco/Net/SecureStreamSocket.h" #include "Poco/Net/SecureStreamSocket.h"
#include "Poco/Net/SecureStreamSocketImpl.h" #include "Poco/Net/SecureStreamSocketImpl.h"
#include "Poco/Net/SSLManager.h" #include "Poco/Net/SSLManager.h"
#include "Poco/Net/HTTPRequest.h" #include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h" #include "Poco/Net/HTTPResponse.h"
#include "Poco/Net/NetException.h" #include "Poco/Net/NetException.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
using Poco::NumberFormatter; using Poco::NumberFormatter;
using Poco::IllegalStateException; using Poco::IllegalStateException;
namespace Poco { namespace Poco {
namespace Net { namespace Net {
HTTPSClientSession::HTTPSClientSession(): HTTPSClientSession::HTTPSClientSession():
HTTPClientSession(SecureStreamSocket()), HTTPClientSession(SecureStreamSocket()),
_pContext(SSLManager::instance().defaultClientContext()) _pContext(SSLManager::instance().defaultClientContext())
{ {
setPort(HTTPS_PORT); setPort(HTTPS_PORT);
} }
HTTPSClientSession::HTTPSClientSession(const SecureStreamSocket& socket): HTTPSClientSession::HTTPSClientSession(const SecureStreamSocket& socket):
HTTPClientSession(socket), HTTPClientSession(socket),
_pContext(socket.context()) _pContext(socket.context())
{ {
setPort(HTTPS_PORT); setPort(HTTPS_PORT);
} }
HTTPSClientSession::HTTPSClientSession(const std::string& host, Poco::UInt16 port): HTTPSClientSession::HTTPSClientSession(const SecureStreamSocket& socket, Session::Ptr pSession):
HTTPClientSession(SecureStreamSocket()), HTTPClientSession(socket),
_pContext(SSLManager::instance().defaultClientContext()) _pContext(socket.context()),
{ _pSession(pSession)
setHost(host); {
setPort(port); setPort(HTTPS_PORT);
SecureStreamSocket sss(socket()); }
sss.setPeerHostName(host);
}
HTTPSClientSession::HTTPSClientSession(const std::string& host, Poco::UInt16 port):
HTTPClientSession(SecureStreamSocket()),
HTTPSClientSession::HTTPSClientSession(Context::Ptr pContext): _pContext(SSLManager::instance().defaultClientContext())
HTTPClientSession(SecureStreamSocket(pContext)), {
_pContext(pContext) setHost(host);
{ setPort(port);
} SecureStreamSocket sss(socket());
sss.setPeerHostName(host);
}
HTTPSClientSession::HTTPSClientSession(const std::string& host, Poco::UInt16 port, Context::Ptr pContext):
HTTPClientSession(SecureStreamSocket(pContext)),
_pContext(pContext) HTTPSClientSession::HTTPSClientSession(Context::Ptr pContext):
{ HTTPClientSession(SecureStreamSocket(pContext)),
setHost(host); _pContext(pContext)
setPort(port); {
SecureStreamSocket sss(socket()); }
sss.setPeerHostName(host);
}
HTTPSClientSession::HTTPSClientSession(Context::Ptr pContext, Session::Ptr pSession):
HTTPClientSession(SecureStreamSocket(pContext, pSession)),
HTTPSClientSession::~HTTPSClientSession() _pContext(pContext),
{ _pSession(pSession)
} {
}
X509Certificate HTTPSClientSession::serverCertificate()
{ HTTPSClientSession::HTTPSClientSession(const std::string& host, Poco::UInt16 port, Context::Ptr pContext):
SecureStreamSocket sss(socket()); HTTPClientSession(SecureStreamSocket(pContext)),
return sss.peerCertificate(); _pContext(pContext)
} {
setHost(host);
setPort(port);
std::string HTTPSClientSession::proxyRequestPrefix() const SecureStreamSocket sss(socket());
{ sss.setPeerHostName(host);
return std::string(); }
}
HTTPSClientSession::HTTPSClientSession(const std::string& host, Poco::UInt16 port, Context::Ptr pContext, Session::Ptr pSession):
void HTTPSClientSession::connect(const SocketAddress& address) HTTPClientSession(SecureStreamSocket(pContext, pSession)),
{ _pContext(pContext),
if (getProxyHost().empty()) _pSession(pSession)
{ {
HTTPSession::connect(address); setHost(host);
} setPort(port);
else SecureStreamSocket sss(socket());
{ sss.setPeerHostName(host);
HTTPClientSession proxySession(address); }
proxySession.setHost(getProxyHost());
proxySession.setPort(getProxyPort());
SocketAddress targetAddress(getHost(), getPort()); HTTPSClientSession::~HTTPSClientSession()
HTTPRequest proxyRequest(HTTPRequest::HTTP_CONNECT, targetAddress.toString(), HTTPMessage::HTTP_1_1); {
HTTPResponse proxyResponse; }
proxyRequest.set("Proxy-Connection", "keep-alive");
proxyRequest.set("Host", getHost());
proxySession.setKeepAlive(true); bool HTTPSClientSession::secure() const
proxySession.sendRequest(proxyRequest); {
proxySession.receiveResponse(proxyResponse); return true;
if (proxyResponse.getStatus() != HTTPResponse::HTTP_OK) }
throw HTTPException("Cannot establish proxy connection", proxyResponse.getReason());
StreamSocket proxySocket(proxySession.detachSocket()); void HTTPSClientSession::abort()
SecureStreamSocket secureSocket = SecureStreamSocket::attach(proxySocket, getHost(), _pContext); {
attachSocket(secureSocket); SecureStreamSocket sss(socket());
} sss.abort();
} }
} } // namespace Poco::Net X509Certificate HTTPSClientSession::serverCertificate()
{
SecureStreamSocket sss(socket());
return sss.peerCertificate();
}
std::string HTTPSClientSession::proxyRequestPrefix() const
{
return std::string();
}
void HTTPSClientSession::proxyAuthenticate(HTTPRequest& request)
{
}
void HTTPSClientSession::connect(const SocketAddress& address)
{
if (getProxyHost().empty())
{
SecureStreamSocket sss(socket());
if (_pContext->sessionCacheEnabled())
{
sss.useSession(_pSession);
}
HTTPSession::connect(address);
if (_pContext->sessionCacheEnabled())
{
_pSession = sss.currentSession();
}
}
else
{
HTTPClientSession proxySession(address);
proxySession.setHost(getProxyHost());
proxySession.setPort(getProxyPort());
proxySession.setTimeout(getTimeout());
SocketAddress targetAddress(getHost(), getPort());
HTTPRequest proxyRequest(HTTPRequest::HTTP_CONNECT, targetAddress.toString(), HTTPMessage::HTTP_1_1);
HTTPResponse proxyResponse;
proxyRequest.set("Proxy-Connection", "keep-alive");
proxyRequest.set("Host", getHost());
proxyAuthenticateImpl(proxyRequest);
proxySession.setKeepAlive(true);
proxySession.sendRequest(proxyRequest);
proxySession.receiveResponse(proxyResponse);
if (proxyResponse.getStatus() != HTTPResponse::HTTP_OK)
throw HTTPException("Cannot establish proxy connection", proxyResponse.getReason());
StreamSocket proxySocket(proxySession.detachSocket());
SecureStreamSocket secureSocket = SecureStreamSocket::attach(proxySocket, getHost(), _pContext, _pSession);
attachSocket(secureSocket);
if (_pContext->sessionCacheEnabled())
{
_pSession = secureSocket.currentSession();
}
}
}
Session::Ptr HTTPSClientSession::sslSession()
{
return _pSession;
}
} } // namespace Poco::Net

View File

@@ -1,77 +1,78 @@
// //
// HTTPSSessionInstantiator.cpp // HTTPSSessionInstantiator.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp#9 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp#9 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: HTTPSClient // Package: HTTPSClient
// Module: HTTPSSessionInstantiator // Module: HTTPSSessionInstantiator
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/HTTPSSessionInstantiator.h" #include "Poco/Net/HTTPSSessionInstantiator.h"
#include "Poco/Net/HTTPSessionFactory.h" #include "Poco/Net/HTTPSessionFactory.h"
#include "Poco/Net/HTTPSClientSession.h" #include "Poco/Net/HTTPSClientSession.h"
namespace Poco { namespace Poco {
namespace Net { namespace Net {
HTTPSSessionInstantiator::HTTPSSessionInstantiator() HTTPSSessionInstantiator::HTTPSSessionInstantiator()
{ {
} }
HTTPSSessionInstantiator::~HTTPSSessionInstantiator() HTTPSSessionInstantiator::~HTTPSSessionInstantiator()
{ {
} }
HTTPClientSession* HTTPSSessionInstantiator::createClientSession(const Poco::URI& uri) HTTPClientSession* HTTPSSessionInstantiator::createClientSession(const Poco::URI& uri)
{ {
poco_assert (uri.getScheme() == "https"); poco_assert (uri.getScheme() == "https");
HTTPSClientSession* pSession = new HTTPSClientSession(uri.getHost(), uri.getPort()); HTTPSClientSession* pSession = new HTTPSClientSession(uri.getHost(), uri.getPort());
pSession->setProxy(proxyHost(), proxyPort()); pSession->setProxy(proxyHost(), proxyPort());
return pSession; pSession->setProxyCredentials(proxyUsername(), proxyPassword());
} return pSession;
}
void HTTPSSessionInstantiator::registerInstantiator()
{ void HTTPSSessionInstantiator::registerInstantiator()
HTTPSessionFactory::defaultFactory().registerProtocol("https", new HTTPSSessionInstantiator); {
} HTTPSessionFactory::defaultFactory().registerProtocol("https", new HTTPSSessionInstantiator);
}
void HTTPSSessionInstantiator::unregisterInstantiator()
{ void HTTPSSessionInstantiator::unregisterInstantiator()
HTTPSessionFactory::defaultFactory().unregisterProtocol("https"); {
} HTTPSessionFactory::defaultFactory().unregisterProtocol("https");
}
} } // namespace Poco::Net
} } // namespace Poco::Net

View File

@@ -1,154 +1,164 @@
// //
// HTTPSStreamFactory.cpp // HTTPSStreamFactory.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/HTTPSStreamFactory.cpp#10 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/HTTPSStreamFactory.cpp#10 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: HTTPSClient // Package: HTTPSClient
// Module: HTTPSStreamFactory // Module: HTTPSStreamFactory
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/HTTPSStreamFactory.h" #include "Poco/Net/HTTPSStreamFactory.h"
#include "Poco/Net/HTTPSClientSession.h" #include "Poco/Net/HTTPSClientSession.h"
#include "Poco/Net/HTTPIOStream.h" #include "Poco/Net/HTTPIOStream.h"
#include "Poco/Net/HTTPRequest.h" #include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h" #include "Poco/Net/HTTPResponse.h"
#include "Poco/Net/NetException.h" #include "Poco/Net/NetException.h"
#include "Poco/URI.h" #include "Poco/URI.h"
#include "Poco/URIStreamOpener.h" #include "Poco/URIStreamOpener.h"
#include "Poco/UnbufferedStreamBuf.h" #include "Poco/UnbufferedStreamBuf.h"
using Poco::URIStreamFactory; using Poco::URIStreamFactory;
using Poco::URI; using Poco::URI;
using Poco::URIStreamOpener; using Poco::URIStreamOpener;
using Poco::UnbufferedStreamBuf; using Poco::UnbufferedStreamBuf;
namespace Poco { namespace Poco {
namespace Net { namespace Net {
HTTPSStreamFactory::HTTPSStreamFactory(): HTTPSStreamFactory::HTTPSStreamFactory():
_proxyPort(HTTPSession::HTTP_PORT) _proxyPort(HTTPSession::HTTP_PORT)
{ {
} }
HTTPSStreamFactory::HTTPSStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort): HTTPSStreamFactory::HTTPSStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort):
_proxyHost(proxyHost), _proxyHost(proxyHost),
_proxyPort(proxyPort) _proxyPort(proxyPort)
{ {
} }
HTTPSStreamFactory::~HTTPSStreamFactory() HTTPSStreamFactory::HTTPSStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort, const std::string& proxyUsername, const std::string& proxyPassword):
{ _proxyHost(proxyHost),
} _proxyPort(proxyPort),
_proxyUsername(proxyUsername),
_proxyPassword(proxyPassword)
std::istream* HTTPSStreamFactory::open(const URI& uri) {
{ }
poco_assert (uri.getScheme() == "https" || uri.getScheme() == "http");
URI resolvedURI(uri); HTTPSStreamFactory::~HTTPSStreamFactory()
URI proxyUri; {
HTTPClientSession* pSession = 0; }
try
{
bool retry = false; std::istream* HTTPSStreamFactory::open(const URI& uri)
int redirects = 0; {
do poco_assert (uri.getScheme() == "https" || uri.getScheme() == "http");
{
if (resolvedURI.getScheme() != "http") URI resolvedURI(uri);
pSession = new HTTPSClientSession(resolvedURI.getHost(), resolvedURI.getPort()); URI proxyUri;
else HTTPClientSession* pSession = 0;
pSession = new HTTPClientSession(resolvedURI.getHost(), resolvedURI.getPort()); try
if (proxyUri.empty()) {
pSession->setProxy(_proxyHost, _proxyPort); bool retry = false;
else int redirects = 0;
pSession->setProxy(proxyUri.getHost(), proxyUri.getPort()); do
std::string path = resolvedURI.getPathAndQuery(); {
if (path.empty()) path = "/"; if (resolvedURI.getScheme() != "http")
HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1); pSession = new HTTPSClientSession(resolvedURI.getHost(), resolvedURI.getPort());
pSession->sendRequest(req); else
HTTPResponse res; pSession = new HTTPClientSession(resolvedURI.getHost(), resolvedURI.getPort());
std::istream& rs = pSession->receiveResponse(res); if (proxyUri.empty())
bool moved = (res.getStatus() == HTTPResponse::HTTP_MOVED_PERMANENTLY || pSession->setProxy(_proxyHost, _proxyPort);
res.getStatus() == HTTPResponse::HTTP_FOUND || else
res.getStatus() == HTTPResponse::HTTP_SEE_OTHER || pSession->setProxy(proxyUri.getHost(), proxyUri.getPort());
res.getStatus() == HTTPResponse::HTTP_TEMPORARY_REDIRECT); pSession->setProxyCredentials(_proxyUsername, _proxyPassword);
if (moved) std::string path = resolvedURI.getPathAndQuery();
{ if (path.empty()) path = "/";
resolvedURI.resolve(res.get("Location")); HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);
//throw URIRedirection(resolvedURI.toString()); pSession->sendRequest(req);
delete pSession; pSession = 0; HTTPResponse res;
++redirects; std::istream& rs = pSession->receiveResponse(res);
retry = true; bool moved = (res.getStatus() == HTTPResponse::HTTP_MOVED_PERMANENTLY ||
} res.getStatus() == HTTPResponse::HTTP_FOUND ||
else if (res.getStatus() == HTTPResponse::HTTP_OK) res.getStatus() == HTTPResponse::HTTP_SEE_OTHER ||
{ res.getStatus() == HTTPResponse::HTTP_TEMPORARY_REDIRECT);
return new HTTPResponseStream(rs, pSession); if (moved)
} {
else if (res.getStatus() == HTTPResponse::HTTP_USEPROXY && !retry) resolvedURI.resolve(res.get("Location"));
{ //throw URIRedirection(resolvedURI.toString());
// The requested resource MUST be accessed through the proxy delete pSession; pSession = 0;
// given by the Location field. The Location field gives the ++redirects;
// URI of the proxy. The recipient is expected to repeat this retry = true;
// single request via the proxy. 305 responses MUST only be generated by origin servers. }
// only use for one single request! else if (res.getStatus() == HTTPResponse::HTTP_OK)
proxyUri.resolve(res.get("Location")); {
delete pSession; pSession = 0; return new HTTPResponseStream(rs, pSession);
retry = true; // only allow useproxy once }
} else if (res.getStatus() == HTTPResponse::HTTP_USEPROXY && !retry)
else {
{ // The requested resource MUST be accessed through the proxy
delete pSession; pSession = 0; // given by the Location field. The Location field gives the
throw HTTPException(res.getReason(), uri.toString()); // URI of the proxy. The recipient is expected to repeat this
} // single request via the proxy. 305 responses MUST only be generated by origin servers.
} // only use for one single request!
while (retry && redirects < MAX_REDIRECTS); proxyUri.resolve(res.get("Location"));
throw HTTPException("Too many redirects", uri.toString()); delete pSession; pSession = 0;
} retry = true; // only allow useproxy once
catch (...) }
{ else
delete pSession; {
throw; delete pSession; pSession = 0;
} throw HTTPException(res.getReason(), uri.toString());
} }
}
while (retry && redirects < MAX_REDIRECTS);
void HTTPSStreamFactory::registerFactory() throw HTTPException("Too many redirects", uri.toString());
{ }
std::string https("https"); catch (...)
URIStreamOpener::defaultOpener().registerStreamFactory(https, new HTTPSStreamFactory); {
} delete pSession;
throw;
}
} } // namespace Poco::Net }
void HTTPSStreamFactory::registerFactory()
{
std::string https("https");
URIStreamOpener::defaultOpener().registerStreamFactory(https, new HTTPSStreamFactory);
}
} } // namespace Poco::Net

View File

@@ -1,75 +1,83 @@
// //
// KeyFileHandler.cpp // KeyFileHandler.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/KeyFileHandler.cpp#12 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/KeyFileHandler.cpp#12 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: KeyFileHandler // Module: KeyFileHandler
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/KeyFileHandler.h" #include "Poco/Net/KeyFileHandler.h"
#include "Poco/Net/SSLManager.h" #include "Poco/Net/SSLManager.h"
#include "Poco/File.h" #include "Poco/File.h"
#include "Poco/Util/LayeredConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
#include "Poco/Util/Application.h" #include "Poco/Util/Application.h"
#include "Poco/Util/OptionException.h" #include "Poco/Util/OptionException.h"
namespace Poco { namespace Poco {
namespace Net { namespace Net {
const std::string KeyFileHandler::CFG_PRIV_KEY_FILE("privateKeyPassphraseHandler.options.password"); const std::string KeyFileHandler::CFG_PRIV_KEY_FILE("privateKeyPassphraseHandler.options.password");
KeyFileHandler::KeyFileHandler(bool server):PrivateKeyPassphraseHandler(server) KeyFileHandler::KeyFileHandler(bool server):PrivateKeyPassphraseHandler(server)
{ {
} }
KeyFileHandler::~KeyFileHandler() KeyFileHandler::~KeyFileHandler()
{ {
} }
void KeyFileHandler::onPrivateKeyRequested(const void* pSender, std::string& privateKey) void KeyFileHandler::onPrivateKeyRequested(const void* pSender, std::string& privateKey)
{ {
Poco::Util::LayeredConfiguration& config = Poco::Util::Application::instance().config(); try
std::string prefix = serverSide() ? SSLManager::CFG_SERVER_PREFIX : SSLManager::CFG_CLIENT_PREFIX; {
if (!config.hasProperty(prefix + CFG_PRIV_KEY_FILE)) Poco::Util::AbstractConfiguration& config = Poco::Util::Application::instance().config();
{ std::string prefix = serverSide() ? SSLManager::CFG_SERVER_PREFIX : SSLManager::CFG_CLIENT_PREFIX;
throw Poco::Util::EmptyOptionException(std::string("Missing Configuration Entry: ") + prefix + CFG_PRIV_KEY_FILE); if (!config.hasProperty(prefix + CFG_PRIV_KEY_FILE))
} throw Poco::Util::EmptyOptionException(std::string("Missing Configuration Entry: ") + prefix + CFG_PRIV_KEY_FILE);
privateKey = config.getString(prefix + CFG_PRIV_KEY_FILE); privateKey = config.getString(prefix + CFG_PRIV_KEY_FILE);
} }
catch (Poco::NullPointerException&)
{
} } // namespace Poco::Net throw Poco::IllegalStateException(
"An application configuration is required to obtain the private key passphrase, "
"but no Poco::Util::Application instance is available."
);
}
}
} } // namespace Poco::Net

View File

@@ -1,61 +1,61 @@
// //
// PrivateKeyPassphraseHandler.cpp // PrivateKeyPassphraseHandler.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/PrivateKeyPassphraseHandler.cpp#8 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/PrivateKeyPassphraseHandler.cpp#8 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: PrivateKeyPassphraseHandler // Module: PrivateKeyPassphraseHandler
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/PrivateKeyPassphraseHandler.h" #include "Poco/Net/PrivateKeyPassphraseHandler.h"
#include "Poco/Net/SSLManager.h" #include "Poco/Net/SSLManager.h"
#include "Poco/Delegate.h" #include "Poco/Delegate.h"
using Poco::Delegate; using Poco::Delegate;
namespace Poco { namespace Poco {
namespace Net { namespace Net {
PrivateKeyPassphraseHandler::PrivateKeyPassphraseHandler(bool onServerSide): _serverSide(onServerSide) PrivateKeyPassphraseHandler::PrivateKeyPassphraseHandler(bool onServerSide): _serverSide(onServerSide)
{ {
SSLManager::instance().PrivateKeyPassPhrase += Delegate<PrivateKeyPassphraseHandler, std::string>(this, &PrivateKeyPassphraseHandler::onPrivateKeyRequested); SSLManager::instance().PrivateKeyPassphraseRequired += Delegate<PrivateKeyPassphraseHandler, std::string>(this, &PrivateKeyPassphraseHandler::onPrivateKeyRequested);
} }
PrivateKeyPassphraseHandler::~PrivateKeyPassphraseHandler() PrivateKeyPassphraseHandler::~PrivateKeyPassphraseHandler()
{ {
SSLManager::instance().PrivateKeyPassPhrase -= Delegate<PrivateKeyPassphraseHandler, std::string>(this, &PrivateKeyPassphraseHandler::onPrivateKeyRequested); SSLManager::instance().PrivateKeyPassphraseRequired -= Delegate<PrivateKeyPassphraseHandler, std::string>(this, &PrivateKeyPassphraseHandler::onPrivateKeyRequested);
} }
} } // namespace Poco::Net } } // namespace Poco::Net

View File

@@ -0,0 +1,60 @@
//
// RejectCertificateHandler.cpp
//
// $Id: //poco/1.4/NetSSL_OpenSSL/src/RejectCertificateHandler.cpp#1 $
//
// Library: NetSSL_OpenSSL
// Package: SSLCore
// Module: RejectCertificateHandler
//
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/Net/RejectCertificateHandler.h"
namespace Poco {
namespace Net {
RejectCertificateHandler::RejectCertificateHandler(bool server): InvalidCertificateHandler(server)
{
}
RejectCertificateHandler::~RejectCertificateHandler()
{
}
void RejectCertificateHandler::onInvalidCertificate(const void*, VerificationErrorArgs& errorCert)
{
errorCert.setIgnoreError(false);
}
} } // namespace Poco::Net

View File

@@ -1,51 +1,52 @@
// //
// SSLException.cpp // SSLException.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/SSLException.cpp#10 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/SSLException.cpp#10 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: SSLException // Module: SSLException
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/SSLException.h" #include "Poco/Net/SSLException.h"
#include <typeinfo> #include <typeinfo>
namespace Poco { namespace Poco {
namespace Net { namespace Net {
POCO_IMPLEMENT_EXCEPTION(SSLException, NetException, "SSL Exception") POCO_IMPLEMENT_EXCEPTION(SSLException, NetException, "SSL Exception")
POCO_IMPLEMENT_EXCEPTION(SSLContextException, SSLException, "SSL context exception") POCO_IMPLEMENT_EXCEPTION(SSLContextException, SSLException, "SSL context exception")
POCO_IMPLEMENT_EXCEPTION(InvalidCertificateException, SSLException, "Invalid certficate") POCO_IMPLEMENT_EXCEPTION(InvalidCertificateException, SSLException, "Invalid certficate")
POCO_IMPLEMENT_EXCEPTION(CertificateValidationException, SSLException, "Certificate validation error") POCO_IMPLEMENT_EXCEPTION(CertificateValidationException, SSLException, "Certificate validation error")
POCO_IMPLEMENT_EXCEPTION(SSLConnectionUnexpectedlyClosedException, SSLException, "SSL connection unexpectedly closed")
} } // namespace Poco::Net
} } // namespace Poco::Net

View File

@@ -1,300 +1,395 @@
// //
// SSLManager.cpp // SSLManager.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/SSLManager.cpp#15 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/SSLManager.cpp#15 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: SSLManager // Module: SSLManager
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/SSLManager.h" #include "Poco/Net/SSLManager.h"
#include "Poco/Net/Context.h" #include "Poco/Net/Context.h"
#include "Poco/Net/Utility.h" #include "Poco/Net/Utility.h"
#include "Poco/Net/PrivateKeyPassphraseHandler.h" #include "Poco/Net/PrivateKeyPassphraseHandler.h"
#include "Poco/Crypto/OpenSSLInitializer.h" #include "Poco/Crypto/OpenSSLInitializer.h"
#include "Poco/Net/SSLException.h" #include "Poco/Net/SSLException.h"
#include "Poco/SingletonHolder.h" #include "Poco/SingletonHolder.h"
#include "Poco/Delegate.h" #include "Poco/Delegate.h"
#include "Poco/Util/Application.h" #include "Poco/Util/Application.h"
#include "Poco/Util/OptionException.h" #include "Poco/Util/OptionException.h"
#include "Poco/Util/LayeredConfiguration.h"
namespace Poco {
namespace Poco { namespace Net {
namespace Net {
const std::string SSLManager::CFG_PRIV_KEY_FILE("privateKeyFile");
const std::string SSLManager::CFG_PRIV_KEY_FILE("privateKeyFile"); const std::string SSLManager::CFG_CERTIFICATE_FILE("certificateFile");
const std::string SSLManager::CFG_CERTIFICATE_FILE("certificateFile"); const std::string SSLManager::CFG_CA_LOCATION("caConfig");
const std::string SSLManager::CFG_CA_LOCATION("caConfig"); const std::string SSLManager::CFG_VER_MODE("verificationMode");
const std::string SSLManager::CFG_VER_MODE("verificationMode"); const Context::VerificationMode SSLManager::VAL_VER_MODE(Context::VERIFY_STRICT);
const Context::VerificationMode SSLManager::VAL_VER_MODE(Context::VERIFY_STRICT); const std::string SSLManager::CFG_VER_DEPTH("verificationDepth");
const std::string SSLManager::CFG_VER_DEPTH("verificationDepth"); const int SSLManager::VAL_VER_DEPTH(9);
const int SSLManager::VAL_VER_DEPTH(9); const std::string SSLManager::CFG_ENABLE_DEFAULT_CA("loadDefaultCAFile");
const std::string SSLManager::CFG_ENABLE_DEFAULT_CA("loadDefaultCAFile"); const bool SSLManager::VAL_ENABLE_DEFAULT_CA(false);
const bool SSLManager::VAL_ENABLE_DEFAULT_CA(false); const std::string SSLManager::CFG_CIPHER_LIST("cipherList");
const std::string SSLManager::CFG_CYPHER_LIST("cypherList"); const std::string SSLManager::CFG_CYPHER_LIST("cypherList");
const std::string SSLManager::VAL_CYPHER_LIST("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); const std::string SSLManager::VAL_CIPHER_LIST("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
const std::string SSLManager::CFG_DELEGATE_HANDLER("privateKeyPassphraseHandler.name"); const std::string SSLManager::CFG_DELEGATE_HANDLER("privateKeyPassphraseHandler.name");
const std::string SSLManager::VAL_DELEGATE_HANDLER("KeyConsoleHandler"); const std::string SSLManager::VAL_DELEGATE_HANDLER("KeyConsoleHandler");
const std::string SSLManager::CFG_CERTIFICATE_HANDLER("invalidCertificateHandler.name"); const std::string SSLManager::CFG_CERTIFICATE_HANDLER("invalidCertificateHandler.name");
const std::string SSLManager::VAL_CERTIFICATE_HANDLER("ConsoleCertificateHandler"); const std::string SSLManager::VAL_CERTIFICATE_HANDLER("ConsoleCertificateHandler");
const std::string SSLManager::CFG_SERVER_PREFIX("openSSL.server."); const std::string SSLManager::CFG_SERVER_PREFIX("openSSL.server.");
const std::string SSLManager::CFG_CLIENT_PREFIX("openSSL.client."); const std::string SSLManager::CFG_CLIENT_PREFIX("openSSL.client.");
const std::string SSLManager::CFG_CACHE_SESSIONS("cacheSessions");
const std::string SSLManager::CFG_SESSION_ID_CONTEXT("sessionIdContext");
SSLManager::SSLManager() const std::string SSLManager::CFG_SESSION_CACHE_SIZE("sessionCacheSize");
{ const std::string SSLManager::CFG_SESSION_TIMEOUT("sessionTimeout");
Poco::Crypto::OpenSSLInitializer::initialize(); const std::string SSLManager::CFG_EXTENDED_VERIFICATION("extendedVerification");
} #ifdef OPENSSL_FIPS
const std::string SSLManager::CFG_FIPS_MODE("openSSL.fips");
const bool SSLManager::VAL_FIPS_MODE(false);
SSLManager::~SSLManager() #endif
{
PrivateKeyPassPhrase.clear();
ClientVerificationError.clear(); SSLManager::SSLManager()
ServerVerificationError.clear(); {
_ptrDefaultServerContext = 0; // ensure all Context objects go away before we uninitialize OpenSSL. }
_ptrDefaultClientContext = 0;
Poco::Crypto::OpenSSLInitializer::uninitialize();
} SSLManager::~SSLManager()
{
shutdown();
SSLManager& SSLManager::instance() }
{
static Poco::SingletonHolder<SSLManager> singleton;
return *singleton.get(); void SSLManager::shutdown()
} {
PrivateKeyPassphraseRequired.clear();
ClientVerificationError.clear();
void SSLManager::initializeServer(PrivateKeyPassphraseHandlerPtr ptrPassPhraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext) ServerVerificationError.clear();
{ _ptrDefaultServerContext = 0;
_ptrServerPassPhraseHandler = ptrPassPhraseHandler; _ptrDefaultClientContext = 0;
_ptrServerCertificateHandler = ptrHandler; }
_ptrDefaultServerContext = ptrContext;
}
namespace
{
void SSLManager::initializeClient(PrivateKeyPassphraseHandlerPtr ptrPassPhraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext) static Poco::SingletonHolder<SSLManager> singleton;
{ }
_ptrClientPassPhraseHandler = ptrPassPhraseHandler;
_ptrClientCertificateHandler = ptrHandler;
_ptrDefaultClientContext = ptrContext; SSLManager& SSLManager::instance()
} {
return *singleton.get();
}
Context::Ptr SSLManager::defaultServerContext()
{
if (!_ptrDefaultServerContext) void SSLManager::initializeServer(PrivateKeyPassphraseHandlerPtr ptrPassphraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext)
initDefaultContext(true); {
_ptrServerPassphraseHandler = ptrPassphraseHandler;
return _ptrDefaultServerContext; _ptrServerCertificateHandler = ptrHandler;
} _ptrDefaultServerContext = ptrContext;
}
Context::Ptr SSLManager::defaultClientContext()
{ void SSLManager::initializeClient(PrivateKeyPassphraseHandlerPtr ptrPassphraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext)
if (!_ptrDefaultClientContext) {
initDefaultContext(false); _ptrClientPassphraseHandler = ptrPassphraseHandler;
_ptrClientCertificateHandler = ptrHandler;
return _ptrDefaultClientContext; _ptrDefaultClientContext = ptrContext;
} }
SSLManager::PrivateKeyPassphraseHandlerPtr SSLManager::serverPassPhraseHandler() Context::Ptr SSLManager::defaultServerContext()
{ {
if (!_ptrServerPassPhraseHandler) Poco::FastMutex::ScopedLock lock(_mutex);
initPassPhraseHandler(true);
if (!_ptrDefaultServerContext)
return _ptrServerPassPhraseHandler; initDefaultContext(true);
}
return _ptrDefaultServerContext;
}
SSLManager::PrivateKeyPassphraseHandlerPtr SSLManager::clientPassPhraseHandler()
{
if (!_ptrClientPassPhraseHandler) Context::Ptr SSLManager::defaultClientContext()
initPassPhraseHandler(false); {
Poco::FastMutex::ScopedLock lock(_mutex);
return _ptrClientPassPhraseHandler;
} if (!_ptrDefaultClientContext)
initDefaultContext(false);
SSLManager::InvalidCertificateHandlerPtr SSLManager::serverCertificateHandler() return _ptrDefaultClientContext;
{ }
if (!_ptrServerCertificateHandler)
initCertificateHandler(true);
SSLManager::PrivateKeyPassphraseHandlerPtr SSLManager::serverPassphraseHandler()
return _ptrServerCertificateHandler; {
} Poco::FastMutex::ScopedLock lock(_mutex);
if (!_ptrServerPassphraseHandler)
SSLManager::InvalidCertificateHandlerPtr SSLManager::clientCertificateHandler() initPassphraseHandler(true);
{
if (!_ptrClientCertificateHandler) return _ptrServerPassphraseHandler;
initCertificateHandler(false); }
return _ptrClientCertificateHandler;
} SSLManager::PrivateKeyPassphraseHandlerPtr SSLManager::clientPassphraseHandler()
{
Poco::FastMutex::ScopedLock lock(_mutex);
int SSLManager::verifyCallback(bool server, int ok, X509_STORE_CTX* pStore)
{ if (!_ptrClientPassphraseHandler)
if (!ok) initPassphraseHandler(false);
{
X509* pCert = X509_STORE_CTX_get_current_cert(pStore); return _ptrClientPassphraseHandler;
X509Certificate x509(pCert); }
int depth = X509_STORE_CTX_get_error_depth(pStore);
int err = X509_STORE_CTX_get_error(pStore);
std::string error(X509_verify_cert_error_string(err)); SSLManager::InvalidCertificateHandlerPtr SSLManager::serverCertificateHandler()
VerificationErrorArgs args(x509, depth, err, error); {
if (server) Poco::FastMutex::ScopedLock lock(_mutex);
SSLManager::instance().ServerVerificationError.notify(&SSLManager::instance(), args);
else if (!_ptrServerCertificateHandler)
SSLManager::instance().ClientVerificationError.notify(&SSLManager::instance(), args); initCertificateHandler(true);
ok = args.getIgnoreError() ? 1 : 0;
} return _ptrServerCertificateHandler;
}
return ok;
}
SSLManager::InvalidCertificateHandlerPtr SSLManager::clientCertificateHandler()
{
int SSLManager::privateKeyPasswdCallback(char* pBuf, int size, int flag, void* userData) Poco::FastMutex::ScopedLock lock(_mutex);
{
std::string pwd; if (!_ptrClientCertificateHandler)
SSLManager::instance().PrivateKeyPassPhrase.notify(&SSLManager::instance(), pwd); initCertificateHandler(false);
strncpy(pBuf, (char *)(pwd.c_str()), size); return _ptrClientCertificateHandler;
pBuf[size - 1] = '\0'; }
if (size > pwd.length())
size = (int) pwd.length();
int SSLManager::verifyCallback(bool server, int ok, X509_STORE_CTX* pStore)
return size; {
} if (!ok)
{
X509* pCert = X509_STORE_CTX_get_current_cert(pStore);
void SSLManager::initDefaultContext(bool server) X509Certificate x509(pCert, true);
{ int depth = X509_STORE_CTX_get_error_depth(pStore);
if (server && _ptrDefaultServerContext) return; int err = X509_STORE_CTX_get_error(pStore);
if (!server && _ptrDefaultClientContext) return; std::string error(X509_verify_cert_error_string(err));
VerificationErrorArgs args(x509, depth, err, error);
initEvents(server); if (server)
SSLManager::instance().ServerVerificationError.notify(&SSLManager::instance(), args);
Poco::Util::LayeredConfiguration& config = Poco::Util::Application::instance().config(); else
std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX; SSLManager::instance().ClientVerificationError.notify(&SSLManager::instance(), args);
ok = args.getIgnoreError() ? 1 : 0;
// mandatory options }
std::string privKeyFile = config.getString(prefix + CFG_PRIV_KEY_FILE, "");
std::string certFile = config.getString(prefix + CFG_CERTIFICATE_FILE, privKeyFile); return ok;
std::string caLocation = config.getString(prefix + CFG_CA_LOCATION, ""); }
if (certFile.empty() && privKeyFile.empty())
throw SSLException("Configuration error: no certificate file has been specified."); int SSLManager::privateKeyPassphraseCallback(char* pBuf, int size, int flag, void* userData)
{
// optional options for which we have defaults defined std::string pwd;
Context::VerificationMode verMode = VAL_VER_MODE; SSLManager::instance().PrivateKeyPassphraseRequired.notify(&SSLManager::instance(), pwd);
if (config.hasProperty(prefix + CFG_VER_MODE))
{ strncpy(pBuf, (char *)(pwd.c_str()), size);
// either: none, relaxed, strict, once pBuf[size - 1] = '\0';
std::string mode = config.getString(prefix + CFG_VER_MODE); if (size > pwd.length())
verMode = Utility::convertVerificationMode(mode); size = (int) pwd.length();
}
return size;
int verDepth = config.getInt(prefix + CFG_VER_DEPTH, VAL_VER_DEPTH); }
bool loadDefCA = config.getBool(prefix + CFG_ENABLE_DEFAULT_CA, VAL_ENABLE_DEFAULT_CA);
std::string cypherList = config.getString(prefix + CFG_CYPHER_LIST, VAL_CYPHER_LIST);
if (server) void SSLManager::initDefaultContext(bool server)
_ptrDefaultServerContext = new Context(Context::SERVER_USE, privKeyFile, certFile, caLocation, verMode, verDepth, loadDefCA, cypherList); {
else if (server && _ptrDefaultServerContext) return;
_ptrDefaultClientContext = new Context(Context::CLIENT_USE, privKeyFile, certFile, caLocation, verMode, verDepth, loadDefCA, cypherList); if (!server && _ptrDefaultClientContext) return;
}
Poco::Crypto::OpenSSLInitializer openSSLInitializer;
initEvents(server);
void SSLManager::initEvents(bool server) Poco::Util::AbstractConfiguration& config = appConfig();
{
initPassPhraseHandler(server); #ifdef OPENSSL_FIPS
initCertificateHandler(server); bool fipsEnabled = config.getBool(CFG_FIPS_MODE, VAL_FIPS_MODE);
} if (fipsEnabled && !Poco::Crypto::OpenSSLInitializer::isFIPSEnabled())
{
Poco::Crypto::OpenSSLInitializer::enableFIPSMode(true);
void SSLManager::initPassPhraseHandler(bool server) }
{ #endif
if (server && _ptrServerPassPhraseHandler) return;
if (!server && _ptrClientPassPhraseHandler) return; std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX;
std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX; // mandatory options
Poco::Util::LayeredConfiguration& config = Poco::Util::Application::instance().config(); std::string privKeyFile = config.getString(prefix + CFG_PRIV_KEY_FILE, "");
std::string certFile = config.getString(prefix + CFG_CERTIFICATE_FILE, privKeyFile);
std::string className(config.getString(prefix + CFG_DELEGATE_HANDLER, VAL_DELEGATE_HANDLER)); std::string caLocation = config.getString(prefix + CFG_CA_LOCATION, "");
const PrivateKeyFactory* pFactory = 0; if (server && certFile.empty() && privKeyFile.empty())
if (privateKeyFactoryMgr().hasFactory(className)) throw SSLException("Configuration error: no certificate file has been specified");
{
pFactory = privateKeyFactoryMgr().getFactory(className); // optional options for which we have defaults defined
} Context::VerificationMode verMode = VAL_VER_MODE;
if (config.hasProperty(prefix + CFG_VER_MODE))
if (pFactory) {
{ // either: none, relaxed, strict, once
if (server) std::string mode = config.getString(prefix + CFG_VER_MODE);
_ptrServerPassPhraseHandler = pFactory->create(server); verMode = Utility::convertVerificationMode(mode);
else }
_ptrClientPassPhraseHandler = pFactory->create(server);
} int verDepth = config.getInt(prefix + CFG_VER_DEPTH, VAL_VER_DEPTH);
else throw Poco::Util::UnknownOptionException(std::string("No PassPhrasehandler known with the name ") + className); bool loadDefCA = config.getBool(prefix + CFG_ENABLE_DEFAULT_CA, VAL_ENABLE_DEFAULT_CA);
} std::string cipherList = config.getString(prefix + CFG_CIPHER_LIST, VAL_CIPHER_LIST);
cipherList = config.getString(prefix + CFG_CYPHER_LIST, cipherList); // for backwards compatibility
if (server)
void SSLManager::initCertificateHandler(bool server) _ptrDefaultServerContext = new Context(Context::SERVER_USE, privKeyFile, certFile, caLocation, verMode, verDepth, loadDefCA, cipherList);
{ else
if (server && _ptrServerCertificateHandler) return; _ptrDefaultClientContext = new Context(Context::CLIENT_USE, privKeyFile, certFile, caLocation, verMode, verDepth, loadDefCA, cipherList);
if (!server && _ptrClientCertificateHandler) return;
bool cacheSessions = config.getBool(prefix + CFG_CACHE_SESSIONS, false);
std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX; if (server)
Poco::Util::LayeredConfiguration& config = Poco::Util::Application::instance().config(); {
std::string sessionIdContext = config.getString(prefix + CFG_SESSION_ID_CONTEXT, config.getString("application.name", ""));
std::string className(config.getString(prefix+CFG_CERTIFICATE_HANDLER, VAL_CERTIFICATE_HANDLER)); _ptrDefaultServerContext->enableSessionCache(cacheSessions, sessionIdContext);
if (config.hasProperty(prefix + CFG_SESSION_CACHE_SIZE))
const CertificateHandlerFactory* pFactory = 0; {
if (certificateHandlerFactoryMgr().hasFactory(className)) int cacheSize = config.getInt(prefix + CFG_SESSION_CACHE_SIZE);
{ _ptrDefaultServerContext->setSessionCacheSize(cacheSize);
pFactory = certificateHandlerFactoryMgr().getFactory(className); }
} if (config.hasProperty(prefix + CFG_SESSION_TIMEOUT))
{
if (pFactory) int timeout = config.getInt(prefix + CFG_SESSION_TIMEOUT);
{ _ptrDefaultServerContext->setSessionTimeout(timeout);
if (server) }
_ptrServerCertificateHandler = pFactory->create(true); }
else else
_ptrClientCertificateHandler = pFactory->create(false); {
} _ptrDefaultClientContext->enableSessionCache(cacheSessions);
else throw Poco::Util::UnknownOptionException(std::string("No InvalidCertificate handler known with the name ") + className); }
} bool extendedVerification = config.getBool(prefix + CFG_EXTENDED_VERIFICATION, false);
if (server)
_ptrDefaultServerContext->enableExtendedCertificateVerification(extendedVerification);
} } // namespace Poco::Net else
_ptrDefaultClientContext->enableExtendedCertificateVerification(extendedVerification);
}
void SSLManager::initEvents(bool server)
{
initPassphraseHandler(server);
initCertificateHandler(server);
}
void SSLManager::initPassphraseHandler(bool server)
{
if (server && _ptrServerPassphraseHandler) return;
if (!server && _ptrClientPassphraseHandler) return;
std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX;
Poco::Util::AbstractConfiguration& config = appConfig();
std::string className(config.getString(prefix + CFG_DELEGATE_HANDLER, VAL_DELEGATE_HANDLER));
const PrivateKeyFactory* pFactory = 0;
if (privateKeyFactoryMgr().hasFactory(className))
{
pFactory = privateKeyFactoryMgr().getFactory(className);
}
if (pFactory)
{
if (server)
_ptrServerPassphraseHandler = pFactory->create(server);
else
_ptrClientPassphraseHandler = pFactory->create(server);
}
else throw Poco::Util::UnknownOptionException(std::string("No passphrase handler known with the name ") + className);
}
void SSLManager::initCertificateHandler(bool server)
{
if (server && _ptrServerCertificateHandler) return;
if (!server && _ptrClientCertificateHandler) return;
std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX;
Poco::Util::AbstractConfiguration& config = appConfig();
std::string className(config.getString(prefix+CFG_CERTIFICATE_HANDLER, VAL_CERTIFICATE_HANDLER));
const CertificateHandlerFactory* pFactory = 0;
if (certificateHandlerFactoryMgr().hasFactory(className))
{
pFactory = certificateHandlerFactoryMgr().getFactory(className);
}
if (pFactory)
{
if (server)
_ptrServerCertificateHandler = pFactory->create(true);
else
_ptrClientCertificateHandler = pFactory->create(false);
}
else throw Poco::Util::UnknownOptionException(std::string("No InvalidCertificate handler known with the name ") + className);
}
Poco::Util::AbstractConfiguration& SSLManager::appConfig()
{
try
{
return Poco::Util::Application::instance().config();
}
catch (Poco::NullPointerException&)
{
throw Poco::IllegalStateException(
"An application configuration is required to initialize the Poco::Net::SSLManager, "
"but no Poco::Util::Application instance is available."
);
}
}
void initializeSSL()
{
Poco::Crypto::initializeCrypto();
}
void uninitializeSSL()
{
SSLManager::instance().shutdown();
Poco::Crypto::uninitializeCrypto();
}
} } // namespace Poco::Net

View File

@@ -0,0 +1,85 @@
//
// SecureSMTPClientSession.h
//
// $Id: //poco/1.4/NetSSL_OpenSSL/src/SecureSMTPClientSession.cpp#1 $
//
// Library: NetSSL_OpenSSL
// Package: Mail
// Module: SecureSMTPClientSession
//
// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/Net/SecureSMTPClientSession.h"
#include "Poco/Net/SecureStreamSocket.h"
#include "Poco/Net/SSLManager.h"
#include "Poco/Net/DialogSocket.h"
namespace Poco {
namespace Net {
SecureSMTPClientSession::SecureSMTPClientSession(const StreamSocket& socket):
SMTPClientSession(socket)
{
}
SecureSMTPClientSession::SecureSMTPClientSession(const std::string& host, Poco::UInt16 port):
SMTPClientSession(host, port)
{
}
SecureSMTPClientSession::~SecureSMTPClientSession()
{
}
bool SecureSMTPClientSession::startTLS()
{
return startTLS(SSLManager::instance().defaultClientContext());
}
bool SecureSMTPClientSession::startTLS(Context::Ptr pContext)
{
int status = 0;
std::string response;
status = sendCommand("STARTTLS", response);
if (!isPositiveCompletion(status)) return false;
SecureStreamSocket sss(SecureStreamSocket::attach(socket(), pContext));
socket() = sss;
return true;
}
} } // namespace Poco::Net

View File

@@ -1,130 +1,136 @@
// //
// SecureServerSocketImpl.cpp // SecureServerSocketImpl.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureServerSocketImpl.cpp#9 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/SecureServerSocketImpl.cpp#9 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLSockets // Package: SSLSockets
// Module: SecureServerSocketImpl // Module: SecureServerSocketImpl
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/SecureServerSocketImpl.h" #include "Poco/Net/SecureServerSocketImpl.h"
namespace Poco { namespace Poco {
namespace Net { namespace Net {
SecureServerSocketImpl::SecureServerSocketImpl(Context::Ptr pContext): SecureServerSocketImpl::SecureServerSocketImpl(Context::Ptr pContext):
_impl(new ServerSocketImpl, pContext) _impl(new ServerSocketImpl, pContext)
{ {
} }
SecureServerSocketImpl::~SecureServerSocketImpl() SecureServerSocketImpl::~SecureServerSocketImpl()
{ {
} }
SocketImpl* SecureServerSocketImpl::acceptConnection(SocketAddress& clientAddr) SocketImpl* SecureServerSocketImpl::acceptConnection(SocketAddress& clientAddr)
{ {
return _impl.acceptConnection(clientAddr); return _impl.acceptConnection(clientAddr);
} }
void SecureServerSocketImpl::connect(const SocketAddress& address) void SecureServerSocketImpl::connect(const SocketAddress& address)
{ {
throw Poco::InvalidAccessException("Cannot connect() a SecureServerSocket"); throw Poco::InvalidAccessException("Cannot connect() a SecureServerSocket");
} }
void SecureServerSocketImpl::connect(const SocketAddress& address, const Poco::Timespan& timeout) void SecureServerSocketImpl::connect(const SocketAddress& address, const Poco::Timespan& timeout)
{ {
throw Poco::InvalidAccessException("Cannot connect() a SecureServerSocket"); throw Poco::InvalidAccessException("Cannot connect() a SecureServerSocket");
} }
void SecureServerSocketImpl::connectNB(const SocketAddress& address) void SecureServerSocketImpl::connectNB(const SocketAddress& address)
{ {
throw Poco::InvalidAccessException("Cannot connect() a SecureServerSocket"); throw Poco::InvalidAccessException("Cannot connect() a SecureServerSocket");
} }
void SecureServerSocketImpl::bind(const SocketAddress& address, bool reuseAddress) void SecureServerSocketImpl::bind(const SocketAddress& address, bool reuseAddress)
{ {
_impl.bind(address, reuseAddress); _impl.bind(address, reuseAddress);
reset(_impl.sockfd()); reset(_impl.sockfd());
} }
void SecureServerSocketImpl::listen(int backlog) void SecureServerSocketImpl::listen(int backlog)
{ {
_impl.listen(backlog); _impl.listen(backlog);
reset(_impl.sockfd()); reset(_impl.sockfd());
} }
void SecureServerSocketImpl::close() void SecureServerSocketImpl::close()
{ {
reset(); reset();
_impl.close(); _impl.close();
} }
int SecureServerSocketImpl::sendBytes(const void* buffer, int length, int flags) int SecureServerSocketImpl::sendBytes(const void* buffer, int length, int flags)
{ {
throw Poco::InvalidAccessException("Cannot sendBytes() on a SecureServerSocket"); throw Poco::InvalidAccessException("Cannot sendBytes() on a SecureServerSocket");
} }
int SecureServerSocketImpl::receiveBytes(void* buffer, int length, int flags) int SecureServerSocketImpl::receiveBytes(void* buffer, int length, int flags)
{ {
throw Poco::InvalidAccessException("Cannot receiveBytes() on a SecureServerSocket"); throw Poco::InvalidAccessException("Cannot receiveBytes() on a SecureServerSocket");
} }
int SecureServerSocketImpl::sendTo(const void* buffer, int length, const SocketAddress& address, int flags) int SecureServerSocketImpl::sendTo(const void* buffer, int length, const SocketAddress& address, int flags)
{ {
throw Poco::InvalidAccessException("Cannot sendTo() on a SecureServerSocket"); throw Poco::InvalidAccessException("Cannot sendTo() on a SecureServerSocket");
} }
int SecureServerSocketImpl::receiveFrom(void* buffer, int length, SocketAddress& address, int flags) int SecureServerSocketImpl::receiveFrom(void* buffer, int length, SocketAddress& address, int flags)
{ {
throw Poco::InvalidAccessException("Cannot receiveFrom() on a SecureServerSocket"); throw Poco::InvalidAccessException("Cannot receiveFrom() on a SecureServerSocket");
} }
void SecureServerSocketImpl::sendUrgent(unsigned char data) void SecureServerSocketImpl::sendUrgent(unsigned char data)
{ {
throw Poco::InvalidAccessException("Cannot sendUrgent() on a SecureServerSocket"); throw Poco::InvalidAccessException("Cannot sendUrgent() on a SecureServerSocket");
} }
} } // namespace Poco::Net bool SecureServerSocketImpl::secure() const
{
return true;
}
} } // namespace Poco::Net

View File

@@ -1,386 +1,495 @@
// //
// SecureSocketImpl.cpp // SecureSocketImpl.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureSocketImpl.cpp#30 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/SecureSocketImpl.cpp#30 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLSockets // Package: SSLSockets
// Module: SecureSocketImpl // Module: SecureSocketImpl
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/SecureSocketImpl.h" #include "Poco/Net/SecureSocketImpl.h"
#include "Poco/Net/SSLException.h" #include "Poco/Net/SSLException.h"
#include "Poco/Net/Context.h" #include "Poco/Net/Context.h"
#include "Poco/Net/X509Certificate.h" #include "Poco/Net/X509Certificate.h"
#include "Poco/Net/Utility.h" #include "Poco/Net/Utility.h"
#include "Poco/Net/SecureStreamSocket.h" #include "Poco/Net/SecureStreamSocket.h"
#include "Poco/Net/SecureStreamSocketImpl.h" #include "Poco/Net/SecureStreamSocketImpl.h"
#include "Poco/Net/StreamSocketImpl.h" #include "Poco/Net/StreamSocketImpl.h"
#include "Poco/Net/StreamSocket.h" #include "Poco/Net/StreamSocket.h"
#include "Poco/Net/NetException.h" #include "Poco/Net/NetException.h"
#include "Poco/Net/DNS.h" #include "Poco/Net/DNS.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
#include "Poco/NumberParser.h" #include "Poco/NumberParser.h"
#include <openssl/x509v3.h> #include "Poco/Format.h"
#include <openssl/err.h> #include <openssl/x509v3.h>
#include <openssl/err.h>
using Poco::IOException;
using Poco::TimeoutException; using Poco::IOException;
using Poco::InvalidArgumentException; using Poco::TimeoutException;
using Poco::NumberFormatter; using Poco::InvalidArgumentException;
using Poco::Timespan; using Poco::NumberFormatter;
using Poco::Timespan;
// workaround for C++-incompatible macro
#define POCO_BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(void*)((n)?"a":NULL)) // workaround for C++-incompatible macro
#define POCO_BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(void*)((n)?"a":NULL))
namespace Poco {
namespace Net { namespace Poco {
namespace Net {
SecureSocketImpl::SecureSocketImpl(Poco::AutoPtr<SocketImpl> pSocketImpl, Context::Ptr pContext):
_pSSL(0), SecureSocketImpl::SecureSocketImpl(Poco::AutoPtr<SocketImpl> pSocketImpl, Context::Ptr pContext):
_pSocket(pSocketImpl), _pSSL(0),
_pContext(pContext) _pSocket(pSocketImpl),
{ _pContext(pContext),
poco_check_ptr (_pSocket); _needHandshake(false)
poco_check_ptr (_pContext); {
} poco_check_ptr (_pSocket);
poco_check_ptr (_pContext);
}
SecureSocketImpl::~SecureSocketImpl()
{
close(); SecureSocketImpl::~SecureSocketImpl()
} {
try
{
SocketImpl* SecureSocketImpl::acceptConnection(SocketAddress& clientAddr) reset();
{ }
poco_assert (!_pSSL); catch (...)
{
StreamSocket ss = _pSocket->acceptConnection(clientAddr); }
Poco::AutoPtr<SecureStreamSocketImpl> pSecureStreamSocketImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(ss.impl()), _pContext); }
pSecureStreamSocketImpl->acceptSSL();
pSecureStreamSocketImpl->duplicate();
return pSecureStreamSocketImpl; SocketImpl* SecureSocketImpl::acceptConnection(SocketAddress& clientAddr)
} {
poco_assert (!_pSSL);
void SecureSocketImpl::acceptSSL() StreamSocket ss = _pSocket->acceptConnection(clientAddr);
{ Poco::AutoPtr<SecureStreamSocketImpl> pSecureStreamSocketImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(ss.impl()), _pContext);
poco_assert (!_pSSL); pSecureStreamSocketImpl->acceptSSL();
pSecureStreamSocketImpl->duplicate();
BIO* pBIO = BIO_new(BIO_s_socket()); return pSecureStreamSocketImpl;
if (!pBIO) throw SSLException("Cannot create BIO object"); }
BIO_set_fd(pBIO, _pSocket->sockfd(), BIO_NOCLOSE);
_pSSL = SSL_new(_pContext->sslContext()); void SecureSocketImpl::acceptSSL()
if (!_pSSL) {
{ poco_assert (!_pSSL);
BIO_free(pBIO);
throw SSLException("Cannot create SSL object"); BIO* pBIO = BIO_new(BIO_s_socket());
} if (!pBIO) throw SSLException("Cannot create BIO object");
SSL_set_bio(_pSSL, pBIO, pBIO); BIO_set_fd(pBIO, static_cast<int>(_pSocket->sockfd()), BIO_NOCLOSE);
try _pSSL = SSL_new(_pContext->sslContext());
{ if (!_pSSL)
if (_pSocket->getBlocking()) {
{ BIO_free(pBIO);
int err = SSL_accept(_pSSL); throw SSLException("Cannot create SSL object");
if (err > 0) }
{ SSL_set_bio(_pSSL, pBIO, pBIO);
std::string clientName = _pSocket->peerAddress().host().toString(); SSL_set_accept_state(_pSSL);
long certErr = verifyCertificate(clientName); _needHandshake = true;
if (certErr != X509_V_OK) }
{
std::string msg = Utility::convertCertificateError(certErr);
throw CertificateValidationException("Unacceptable certificate from " + clientName, msg); void SecureSocketImpl::connect(const SocketAddress& address, bool performHandshake)
} {
} if (_pSSL) reset();
else
{ poco_assert (!_pSSL);
handleError(err);
} _pSocket->connect(address);
} connectSSL(performHandshake);
else }
{
SSL_set_accept_state(_pSSL);
} void SecureSocketImpl::connect(const SocketAddress& address, const Poco::Timespan& timeout, bool performHandshake)
} {
catch (...) if (_pSSL) reset();
{
SSL_shutdown(_pSSL); poco_assert (!_pSSL);
SSL_free(_pSSL);
_pSSL = 0; _pSocket->connect(address, timeout);
throw; connectSSL(performHandshake);
} }
}
void SecureSocketImpl::connectNB(const SocketAddress& address)
void SecureSocketImpl::connect(const SocketAddress& address, const std::string& hostName) {
{ if (_pSSL) reset();
poco_assert (!_pSSL);
poco_assert (!_pSSL);
_pSocket->connect(address);
connectSSL(hostName); _pSocket->connectNB(address);
} connectSSL(false);
}
void SecureSocketImpl::connect(const SocketAddress& address, const std::string& hostName, const Poco::Timespan& timeout)
{ void SecureSocketImpl::connectSSL(bool performHandshake)
poco_assert (!_pSSL); {
poco_assert (!_pSSL);
_pSocket->connect(address, timeout); poco_assert (_pSocket->initialized());
connectSSL(hostName);
} BIO* pBIO = BIO_new(BIO_s_socket());
if (!pBIO) throw SSLException("Cannot create SSL BIO object");
BIO_set_fd(pBIO, static_cast<int>(_pSocket->sockfd()), BIO_NOCLOSE);
void SecureSocketImpl::connectNB(const SocketAddress& address, const std::string& hostName)
{ _pSSL = SSL_new(_pContext->sslContext());
poco_assert (!_pSSL); if (!_pSSL)
{
_pSocket->connectNB(address); BIO_free(pBIO);
connectSSL(hostName); throw SSLException("Cannot create SSL object");
} }
SSL_set_bio(_pSSL, pBIO, pBIO);
void SecureSocketImpl::connectSSL(const std::string& hostName) if (_pSession)
{ {
poco_assert (!_pSSL); SSL_set_session(_pSSL, _pSession->sslSession());
poco_assert (_pSocket->initialized()); }
BIO* pBIO = BIO_new(BIO_s_socket()); try
if (!pBIO) throw SSLException("Cannot create SSL BIO object"); {
BIO_set_fd(pBIO, _pSocket->sockfd(), BIO_NOCLOSE); if (performHandshake && _pSocket->getBlocking())
{
_pSSL = SSL_new(_pContext->sslContext()); int ret = SSL_connect(_pSSL);
if (!_pSSL) handleError(ret);
{ verifyPeerCertificate();
BIO_free(pBIO); }
throw SSLException("Cannot create SSL object"); else
} {
SSL_set_bio(_pSSL, pBIO, pBIO); SSL_set_connect_state(_pSSL);
_needHandshake = true;
try }
{ }
if (_pSocket->getBlocking()) catch (...)
{ {
int ret = SSL_connect(_pSSL); SSL_free(_pSSL);
handleError(ret); _pSSL = 0;
throw;
long certErr = verifyCertificate(hostName); }
if (certErr != X509_V_OK) }
{
std::string msg = Utility::convertCertificateError(certErr);
throw InvalidCertificateException(msg); void SecureSocketImpl::bind(const SocketAddress& address, bool reuseAddress)
} {
} poco_check_ptr (_pSocket);
else
{ _pSocket->bind(address, reuseAddress);
SSL_set_connect_state(_pSSL); }
}
}
catch (...) void SecureSocketImpl::listen(int backlog)
{ {
SSL_free(_pSSL); poco_check_ptr (_pSocket);
_pSSL = 0;
throw; _pSocket->listen(backlog);
} }
}
void SecureSocketImpl::shutdown()
void SecureSocketImpl::bind(const SocketAddress& address, bool reuseAddress) {
{ if (_pSSL)
poco_check_ptr (_pSocket); {
// Don't shut down the socket more than once.
_pSocket->bind(address, reuseAddress); int shutdownState = SSL_get_shutdown(_pSSL);
} bool shutdownSent = (shutdownState & SSL_SENT_SHUTDOWN) == SSL_SENT_SHUTDOWN;
if (!shutdownSent)
{
void SecureSocketImpl::listen(int backlog) // A proper clean shutdown would require us to
{ // retry the shutdown if we get a zero return
poco_check_ptr (_pSocket); // value, until SSL_shutdown() returns 1.
// However, this will lead to problems with
_pSocket->listen(backlog); // most web browsers, so we just set the shutdown
} // flag by calling SSL_shutdown() once and be
// done with it.
int rc = SSL_shutdown(_pSSL);
void SecureSocketImpl::shutdown() if (rc < 0) handleError(rc);
{ SSL_clear(_pSSL);
if (_pSSL) SSL_free(_pSSL);
{ _pSSL = 0;
// A proper clean shutdown would require us to }
// retry the shutdown if we get a zero return }
// value, until SSL_shutdown() returns 1. }
// However, this will lead to problems with
// most web browsers, so we just set the shutdown void SecureSocketImpl::close()
// flag by calling SSL_shutdown() once and be {
// done with it. shutdown();
int rc = SSL_shutdown(_pSSL); _pSocket->close();
if (rc < 0) handleError(rc); }
SSL_clear(_pSSL);
SSL_free(_pSSL);
_pSSL = 0; int SecureSocketImpl::sendBytes(const void* buffer, int length, int flags)
} {
} poco_assert (_pSocket->initialized());
poco_check_ptr (_pSSL);
void SecureSocketImpl::close() int rc;
{ if (_needHandshake)
shutdown(); {
_pSocket->close(); rc = completeHandshake();
} if (rc == 1)
verifyPeerCertificate();
else if (rc == 0)
int SecureSocketImpl::sendBytes(const void* buffer, int length, int flags) throw SSLConnectionUnexpectedlyClosedException();
{ else
poco_assert (_pSocket->initialized()); return rc;
poco_check_ptr (_pSSL); }
do
int rc; {
do rc = SSL_write(_pSSL, buffer, length);
{ }
rc = SSL_write(_pSSL, buffer, length); while (rc <= 0 && _pSocket->lastError() == POCO_EINTR);
} if (rc <= 0)
while (rc <= 0 && _pSocket->lastError() == POCO_EINTR); {
if (rc <= 0) rc = handleError(rc);
{ if (rc == 0) throw SSLConnectionUnexpectedlyClosedException();
return handleError(rc); }
} return rc;
return rc; }
}
int SecureSocketImpl::receiveBytes(void* buffer, int length, int flags)
int SecureSocketImpl::receiveBytes(void* buffer, int length, int flags) {
{ poco_assert (_pSocket->initialized());
poco_assert (_pSocket->initialized()); poco_check_ptr (_pSSL);
poco_check_ptr (_pSSL);
int rc;
int rc; if (_needHandshake)
do {
{ rc = completeHandshake();
rc = SSL_read(_pSSL, buffer, length); if (rc == 1)
} verifyPeerCertificate();
while (rc <= 0 && _pSocket->lastError() == POCO_EINTR); else
if (rc <= 0) return rc;
{ }
return handleError(rc); do
} {
return rc; rc = SSL_read(_pSSL, buffer, length);
} }
while (rc <= 0 && _pSocket->lastError() == POCO_EINTR);
if (rc <= 0)
long SecureSocketImpl::verifyCertificate(const std::string& hostName) {
{ return handleError(rc);
Context::VerificationMode mode = _pContext->verificationMode(); }
if (mode == Context::VERIFY_NONE || (isLocalHost(hostName) && mode != Context::VERIFY_STRICT)) return rc;
{ }
return X509_V_OK;
}
int SecureSocketImpl::available() const
X509* pCert = SSL_get_peer_certificate(_pSSL); {
if (pCert) poco_check_ptr (_pSSL);
{
X509Certificate cert(pCert); return SSL_pending(_pSSL);
return cert.verify(hostName); }
}
else return X509_V_OK;
} int SecureSocketImpl::completeHandshake()
{
poco_assert (_pSocket->initialized());
poco_check_ptr (_pSSL);
bool SecureSocketImpl::isLocalHost(const std::string& hostName)
{ int rc;
SocketAddress addr(hostName, 0); do
return addr.host().isLoopback(); {
} rc = SSL_do_handshake(_pSSL);
}
while (rc <= 0 && _pSocket->lastError() == POCO_EINTR);
X509* SecureSocketImpl::peerCertificate() const if (rc <= 0)
{ {
if (_pSSL) return handleError(rc);
return SSL_get_peer_certificate(_pSSL); }
else _needHandshake = false;
return 0; return rc;
} }
int SecureSocketImpl::handleError(int rc) void SecureSocketImpl::verifyPeerCertificate()
{ {
if (rc > 0) return rc; if (_peerHostName.empty())
_peerHostName = _pSocket->peerAddress().host().toString();
int sslError = SSL_get_error(_pSSL, rc);
switch (sslError) verifyPeerCertificate(_peerHostName);
{ }
case SSL_ERROR_ZERO_RETURN:
return 0;
case SSL_ERROR_WANT_READ: void SecureSocketImpl::verifyPeerCertificate(const std::string& hostName)
return SecureStreamSocket::ERR_SSL_WANT_READ; {
case SSL_ERROR_WANT_WRITE: long certErr = verifyPeerCertificateImpl(hostName);
return SecureStreamSocket::ERR_SSL_WANT_WRITE; if (certErr != X509_V_OK)
case SSL_ERROR_WANT_CONNECT: {
case SSL_ERROR_WANT_ACCEPT: std::string msg = Utility::convertCertificateError(certErr);
case SSL_ERROR_WANT_X509_LOOKUP: throw CertificateValidationException("Unacceptable certificate from " + hostName, msg);
// these should not occur }
poco_bugcheck(); }
return rc;
case SSL_ERROR_SYSCALL:
case SSL_ERROR_SSL: long SecureSocketImpl::verifyPeerCertificateImpl(const std::string& hostName)
{ {
long lastError = ERR_get_error(); Context::VerificationMode mode = _pContext->verificationMode();
if (lastError == 0) if (mode == Context::VERIFY_NONE || !_pContext->extendedCertificateVerificationEnabled() ||
{ (isLocalHost(hostName) && mode != Context::VERIFY_STRICT))
if (rc == 0) {
{ return X509_V_OK;
throw SSLException("The underlying socket connection has been unexpectedly closed"); }
}
else if (rc == -1) X509* pCert = SSL_get_peer_certificate(_pSSL);
{ if (pCert)
SecureStreamSocketImpl::error("The BIO reported an error"); {
} X509Certificate cert(pCert);
} return cert.verify(hostName) ? X509_V_OK : X509_V_ERR_APPLICATION_VERIFICATION;
else }
{ else return X509_V_OK;
char buffer[256]; }
ERR_error_string_n(lastError, buffer, sizeof(buffer));
std::string msg(buffer);
throw SSLException(msg); bool SecureSocketImpl::isLocalHost(const std::string& hostName)
} {
} SocketAddress addr(hostName, 0);
break; return addr.host().isLoopback();
default: }
break;
}
return rc; X509* SecureSocketImpl::peerCertificate() const
} {
if (_pSSL)
return SSL_get_peer_certificate(_pSSL);
} } // namespace Poco::Net else
return 0;
}
int SecureSocketImpl::handleError(int rc)
{
if (rc > 0) return rc;
int sslError = SSL_get_error(_pSSL, rc);
switch (sslError)
{
case SSL_ERROR_ZERO_RETURN:
return 0;
case SSL_ERROR_WANT_READ:
return SecureStreamSocket::ERR_SSL_WANT_READ;
case SSL_ERROR_WANT_WRITE:
return SecureStreamSocket::ERR_SSL_WANT_WRITE;
case SSL_ERROR_WANT_CONNECT:
case SSL_ERROR_WANT_ACCEPT:
case SSL_ERROR_WANT_X509_LOOKUP:
// these should not occur
poco_bugcheck();
return rc;
default:
{
long lastError = ERR_get_error();
if (lastError == 0)
{
if (rc == 0)
{
throw SSLConnectionUnexpectedlyClosedException();
}
else
{
SecureStreamSocketImpl::error(Poco::format("The BIO reported an error: %d", rc));
}
}
else
{
char buffer[256];
ERR_error_string_n(lastError, buffer, sizeof(buffer));
std::string msg(buffer);
throw SSLException(msg);
}
}
break;
}
return rc;
}
void SecureSocketImpl::setPeerHostName(const std::string& peerHostName)
{
_peerHostName = peerHostName;
}
void SecureSocketImpl::reset()
{
close();
if (_pSSL)
{
SSL_free(_pSSL);
_pSSL = 0;
}
}
void SecureSocketImpl::abort()
{
_pSocket->shutdown();
}
Session::Ptr SecureSocketImpl::currentSession()
{
if (_pSSL)
{
SSL_SESSION* pSession = SSL_get1_session(_pSSL);
if (pSession)
{
if (_pSession && pSession == _pSession->sslSession())
{
SSL_SESSION_free(pSession);
return _pSession;
}
else return new Session(pSession);
}
}
return 0;
}
void SecureSocketImpl::useSession(Session::Ptr pSession)
{
_pSession = pSession;
}
bool SecureSocketImpl::sessionWasReused()
{
if (_pSSL)
return SSL_session_reused(_pSSL) != 0;
else
return false;
}
} } // namespace Poco::Net

View File

@@ -1,186 +1,291 @@
// //
// SecureStreamSocket.cpp // SecureStreamSocket.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureStreamSocket.cpp#11 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/SecureStreamSocket.cpp#11 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLSockets // Package: SSLSockets
// Module: SecureStreamSocket // Module: SecureStreamSocket
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/SecureStreamSocket.h" #include "Poco/Net/SecureStreamSocket.h"
#include "Poco/Net/SecureStreamSocketImpl.h" #include "Poco/Net/SecureStreamSocketImpl.h"
#include "Poco/Net/SocketImpl.h" #include "Poco/Net/SocketImpl.h"
#include "Poco/Net/SSLManager.h" #include "Poco/Net/SSLManager.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
using Poco::InvalidArgumentException; using Poco::InvalidArgumentException;
namespace Poco { namespace Poco {
namespace Net { namespace Net {
SecureStreamSocket::SecureStreamSocket(): SecureStreamSocket::SecureStreamSocket():
StreamSocket(new SecureStreamSocketImpl(SSLManager::instance().defaultClientContext())) StreamSocket(new SecureStreamSocketImpl(SSLManager::instance().defaultClientContext()))
{ {
} }
SecureStreamSocket::SecureStreamSocket(Context::Ptr pContext): SecureStreamSocket::SecureStreamSocket(Context::Ptr pContext):
StreamSocket(new SecureStreamSocketImpl(pContext)) StreamSocket(new SecureStreamSocketImpl(pContext))
{ {
} }
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address): SecureStreamSocket::SecureStreamSocket(Context::Ptr pContext, Session::Ptr pSession):
StreamSocket(new SecureStreamSocketImpl(SSLManager::instance().defaultClientContext())) StreamSocket(new SecureStreamSocketImpl(pContext))
{ {
connect(address); useSession(pSession);
} }
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName): SecureStreamSocket::SecureStreamSocket(const SocketAddress& address):
StreamSocket(new SecureStreamSocketImpl(SSLManager::instance().defaultClientContext())) StreamSocket(new SecureStreamSocketImpl(SSLManager::instance().defaultClientContext()))
{ {
static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName); connect(address);
connect(address); }
}
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName):
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext): StreamSocket(new SecureStreamSocketImpl(SSLManager::instance().defaultClientContext()))
StreamSocket(new SecureStreamSocketImpl(pContext)) {
{ static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName);
connect(address); connect(address);
} }
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext): SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext):
StreamSocket(new SecureStreamSocketImpl(pContext)) StreamSocket(new SecureStreamSocketImpl(pContext))
{ {
static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName); connect(address);
connect(address); }
}
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext, Session::Ptr pSession):
SecureStreamSocket::SecureStreamSocket(const Socket& socket): StreamSocket(new SecureStreamSocketImpl(pContext))
StreamSocket(socket) {
{ useSession(pSession);
if (!dynamic_cast<SecureStreamSocketImpl*>(impl())) connect(address);
throw InvalidArgumentException("Cannot assign incompatible socket"); }
}
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext):
SecureStreamSocket::SecureStreamSocket(SocketImpl* pImpl): StreamSocket(new SecureStreamSocketImpl(pContext))
StreamSocket(pImpl) {
{ static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName);
if (!dynamic_cast<SecureStreamSocketImpl*>(impl())) connect(address);
throw InvalidArgumentException("Cannot assign incompatible socket"); }
}
SecureStreamSocket::SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext, Session::Ptr pSession):
SecureStreamSocket::~SecureStreamSocket() StreamSocket(new SecureStreamSocketImpl(pContext))
{ {
} static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName);
useSession(pSession);
connect(address);
SecureStreamSocket& SecureStreamSocket::operator = (const Socket& socket) }
{
if (dynamic_cast<SecureStreamSocketImpl*>(socket.impl()))
StreamSocket::operator = (socket); SecureStreamSocket::SecureStreamSocket(const Socket& socket):
else StreamSocket(socket)
throw InvalidArgumentException("Cannot assign incompatible socket"); {
return *this; if (!dynamic_cast<SecureStreamSocketImpl*>(impl()))
} throw InvalidArgumentException("Cannot assign incompatible socket");
}
X509Certificate SecureStreamSocket::peerCertificate() const
{ SecureStreamSocket::SecureStreamSocket(SocketImpl* pImpl):
return static_cast<SecureStreamSocketImpl*>(impl())->peerCertificate(); StreamSocket(pImpl)
} {
if (!dynamic_cast<SecureStreamSocketImpl*>(impl()))
throw InvalidArgumentException("Cannot assign incompatible socket");
void SecureStreamSocket::setPeerHostName(const std::string& hostName) }
{
static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName);
} SecureStreamSocket::~SecureStreamSocket()
{
}
const std::string& SecureStreamSocket::getPeerHostName() const
{
return static_cast<SecureStreamSocketImpl*>(impl())->getPeerHostName(); SecureStreamSocket& SecureStreamSocket::operator = (const Socket& socket)
} {
if (dynamic_cast<SecureStreamSocketImpl*>(socket.impl()))
StreamSocket::operator = (socket);
SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket) else
{ throw InvalidArgumentException("Cannot assign incompatible socket");
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), SSLManager::instance().defaultClientContext()); return *this;
SecureStreamSocket result(pImpl); }
pImpl->connectSSL();
return result;
} bool SecureStreamSocket::havePeerCertificate() const
{
return static_cast<SecureStreamSocketImpl*>(impl())->havePeerCertificate();
SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket, Context::Ptr pContext) }
{
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), pContext);
SecureStreamSocket result(pImpl); X509Certificate SecureStreamSocket::peerCertificate() const
pImpl->connectSSL(); {
return result; return static_cast<SecureStreamSocketImpl*>(impl())->peerCertificate();
} }
SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket, const std::string& peerHostName) void SecureStreamSocket::setPeerHostName(const std::string& hostName)
{ {
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), SSLManager::instance().defaultClientContext()); static_cast<SecureStreamSocketImpl*>(impl())->setPeerHostName(hostName);
SecureStreamSocket result(pImpl); }
result.setPeerHostName(peerHostName);
pImpl->connectSSL();
return result; const std::string& SecureStreamSocket::getPeerHostName() const
} {
return static_cast<SecureStreamSocketImpl*>(impl())->getPeerHostName();
}
SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket, const std::string& peerHostName, Context::Ptr pContext)
{
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), pContext); SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket)
SecureStreamSocket result(pImpl); {
result.setPeerHostName(peerHostName); SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), SSLManager::instance().defaultClientContext());
pImpl->connectSSL(); SecureStreamSocket result(pImpl);
return result; pImpl->connectSSL();
} return result;
}
Context::Ptr SecureStreamSocket::context() const
{ SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket, Context::Ptr pContext)
return static_cast<SecureStreamSocketImpl*>(impl())->context(); {
} SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), pContext);
SecureStreamSocket result(pImpl);
pImpl->connectSSL();
} } // namespace Poco::Net return result;
}
SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket, Context::Ptr pContext, Session::Ptr pSession)
{
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), pContext);
SecureStreamSocket result(pImpl);
result.useSession(pSession);
pImpl->connectSSL();
return result;
}
SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket, const std::string& peerHostName)
{
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), SSLManager::instance().defaultClientContext());
SecureStreamSocket result(pImpl);
result.setPeerHostName(peerHostName);
pImpl->connectSSL();
return result;
}
SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket, const std::string& peerHostName, Context::Ptr pContext)
{
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), pContext);
SecureStreamSocket result(pImpl);
result.setPeerHostName(peerHostName);
pImpl->connectSSL();
return result;
}
SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket, const std::string& peerHostName, Context::Ptr pContext, Session::Ptr pSession)
{
SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>(streamSocket.impl()), pContext);
SecureStreamSocket result(pImpl);
result.setPeerHostName(peerHostName);
result.useSession(pSession);
pImpl->connectSSL();
return result;
}
Context::Ptr SecureStreamSocket::context() const
{
return static_cast<SecureStreamSocketImpl*>(impl())->context();
}
void SecureStreamSocket::setLazyHandshake(bool flag)
{
static_cast<SecureStreamSocketImpl*>(impl())->setLazyHandshake(flag);
}
bool SecureStreamSocket::getLazyHandshake() const
{
return static_cast<SecureStreamSocketImpl*>(impl())->getLazyHandshake();
}
void SecureStreamSocket::verifyPeerCertificate()
{
static_cast<SecureStreamSocketImpl*>(impl())->verifyPeerCertificate();
}
void SecureStreamSocket::verifyPeerCertificate(const std::string& hostName)
{
static_cast<SecureStreamSocketImpl*>(impl())->verifyPeerCertificate(hostName);
}
int SecureStreamSocket::completeHandshake()
{
return static_cast<SecureStreamSocketImpl*>(impl())->completeHandshake();
}
Session::Ptr SecureStreamSocket::currentSession()
{
return static_cast<SecureStreamSocketImpl*>(impl())->currentSession();
}
void SecureStreamSocket::useSession(Session::Ptr pSession)
{
static_cast<SecureStreamSocketImpl*>(impl())->useSession(pSession);
}
bool SecureStreamSocket::sessionWasReused()
{
return static_cast<SecureStreamSocketImpl*>(impl())->sessionWasReused();
}
void SecureStreamSocket::abort()
{
static_cast<SecureStreamSocketImpl*>(impl())->abort();
}
} } // namespace Poco::Net

View File

@@ -1,197 +1,258 @@
// //
// SecureStreamSocketImpl.cpp // SecureStreamSocketImpl.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureStreamSocketImpl.cpp#9 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/SecureStreamSocketImpl.cpp#9 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLSockets // Package: SSLSockets
// Module: SecureStreamSocketImpl // Module: SecureStreamSocketImpl
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/SecureStreamSocketImpl.h" #include "Poco/Net/SecureStreamSocketImpl.h"
#include "Poco/Net/SSLException.h" #include "Poco/Net/SSLException.h"
#include "Poco/Thread.h"
namespace Poco {
namespace Net { namespace Poco {
namespace Net {
SecureStreamSocketImpl::SecureStreamSocketImpl(Context::Ptr pContext):
_impl(new StreamSocketImpl, pContext) SecureStreamSocketImpl::SecureStreamSocketImpl(Context::Ptr pContext):
{ _impl(new StreamSocketImpl, pContext),
} _lazyHandshake(false)
{
}
SecureStreamSocketImpl::SecureStreamSocketImpl(StreamSocketImpl* pStreamSocket, Context::Ptr pContext):
_impl(pStreamSocket, pContext)
{ SecureStreamSocketImpl::SecureStreamSocketImpl(StreamSocketImpl* pStreamSocket, Context::Ptr pContext):
pStreamSocket->duplicate(); _impl(pStreamSocket, pContext),
reset(_impl.sockfd()); _lazyHandshake(false)
} {
pStreamSocket->duplicate();
reset(_impl.sockfd());
SecureStreamSocketImpl::~SecureStreamSocketImpl() }
{
reset();
} SecureStreamSocketImpl::~SecureStreamSocketImpl()
{
}
SocketImpl* SecureStreamSocketImpl::acceptConnection(SocketAddress& clientAddr)
{
throw Poco::InvalidAccessException("Cannot acceptConnection() on a SecureStreamSocketImpl"); SocketImpl* SecureStreamSocketImpl::acceptConnection(SocketAddress& clientAddr)
} {
throw Poco::InvalidAccessException("Cannot acceptConnection() on a SecureStreamSocketImpl");
}
void SecureStreamSocketImpl::acceptSSL()
{
_impl.acceptSSL(); void SecureStreamSocketImpl::acceptSSL()
} {
_impl.acceptSSL();
}
void SecureStreamSocketImpl::connect(const SocketAddress& address)
{
if (_peerHostName.empty()) _peerHostName = address.host().toString(); void SecureStreamSocketImpl::connect(const SocketAddress& address)
_impl.connect(address, _peerHostName); {
reset(_impl.sockfd()); _impl.connect(address, !_lazyHandshake);
} reset(_impl.sockfd());
}
void SecureStreamSocketImpl::connect(const SocketAddress& address, const Poco::Timespan& timeout)
{ void SecureStreamSocketImpl::connect(const SocketAddress& address, const Poco::Timespan& timeout)
if (_peerHostName.empty()) _peerHostName = address.host().toString(); {
_impl.connect(address, _peerHostName, timeout); _impl.connect(address, timeout, !_lazyHandshake);
reset(_impl.sockfd()); reset(_impl.sockfd());
} }
void SecureStreamSocketImpl::connectNB(const SocketAddress& address) void SecureStreamSocketImpl::connectNB(const SocketAddress& address)
{ {
if (_peerHostName.empty()) _peerHostName = address.host().toString(); _impl.connectNB(address);
_impl.connectNB(address, _peerHostName); reset(_impl.sockfd());
reset(_impl.sockfd()); }
}
void SecureStreamSocketImpl::connectSSL()
void SecureStreamSocketImpl::connectSSL() {
{ _impl.connectSSL(!_lazyHandshake);
if (_peerHostName.empty()) _peerHostName = peerAddress().host().toString(); }
_impl.connectSSL(_peerHostName);
}
void SecureStreamSocketImpl::bind(const SocketAddress& address, bool reuseAddress)
{
void SecureStreamSocketImpl::bind(const SocketAddress& address, bool reuseAddress) throw Poco::InvalidAccessException("Cannot bind() a SecureStreamSocketImpl");
{ }
throw Poco::InvalidAccessException("Cannot bind() a SecureStreamSocketImpl");
}
void SecureStreamSocketImpl::listen(int backlog)
{
void SecureStreamSocketImpl::listen(int backlog) throw Poco::InvalidAccessException("Cannot listen() on a SecureStreamSocketImpl");
{ }
throw Poco::InvalidAccessException("Cannot listen() on a SecureStreamSocketImpl");
}
void SecureStreamSocketImpl::close()
{
void SecureStreamSocketImpl::close() reset();
{ _impl.close();
reset(); }
_impl.close();
}
void SecureStreamSocketImpl::abort()
{
int SecureStreamSocketImpl::sendBytes(const void* buffer, int length, int flags) reset();
{ _impl.abort();
const char* p = reinterpret_cast<const char*>(buffer); }
int remaining = length;
while (remaining > 0)
{ int SecureStreamSocketImpl::sendBytes(const void* buffer, int length, int flags)
int n = _impl.sendBytes(p, length, flags); {
p += n; const char* p = reinterpret_cast<const char*>(buffer);
remaining -= n; int remaining = length;
} int sent = 0;
return length; bool blocking = getBlocking();
} while (remaining > 0)
{
int n = _impl.sendBytes(p, remaining, flags);
int SecureStreamSocketImpl::receiveBytes(void* buffer, int length, int flags) if (n < 0 && !blocking) return n;
{ p += n;
return _impl.receiveBytes(buffer, length, flags); sent += n;
} remaining -= n;
if (blocking && remaining > 0)
Poco::Thread::yield();
int SecureStreamSocketImpl::sendTo(const void* buffer, int length, const SocketAddress& address, int flags) else
{ break;
throw Poco::InvalidAccessException("Cannot sendTo() on a SecureStreamSocketImpl"); }
} return sent;
}
int SecureStreamSocketImpl::receiveFrom(void* buffer, int length, SocketAddress& address, int flags)
{ int SecureStreamSocketImpl::receiveBytes(void* buffer, int length, int flags)
throw Poco::InvalidAccessException("Cannot receiveFrom() on a SecureStreamSocketImpl"); {
} return _impl.receiveBytes(buffer, length, flags);
}
void SecureStreamSocketImpl::sendUrgent(unsigned char data)
{ int SecureStreamSocketImpl::sendTo(const void* buffer, int length, const SocketAddress& address, int flags)
throw Poco::InvalidAccessException("Cannot sendUrgent() on a SecureStreamSocketImpl"); {
} throw Poco::InvalidAccessException("Cannot sendTo() on a SecureStreamSocketImpl");
}
void SecureStreamSocketImpl::shutdownReceive()
{ int SecureStreamSocketImpl::receiveFrom(void* buffer, int length, SocketAddress& address, int flags)
} {
throw Poco::InvalidAccessException("Cannot receiveFrom() on a SecureStreamSocketImpl");
}
void SecureStreamSocketImpl::shutdownSend()
{
} void SecureStreamSocketImpl::sendUrgent(unsigned char data)
{
throw Poco::InvalidAccessException("Cannot sendUrgent() on a SecureStreamSocketImpl");
void SecureStreamSocketImpl::shutdown() }
{
_impl.shutdown();
} int SecureStreamSocketImpl::available()
{
return _impl.available();
void SecureStreamSocketImpl::setPeerHostName(const std::string& peerHostName) }
{
_peerHostName = peerHostName;
} void SecureStreamSocketImpl::shutdownReceive()
{
}
X509Certificate SecureStreamSocketImpl::peerCertificate() const
{
X509* pCert = _impl.peerCertificate(); void SecureStreamSocketImpl::shutdownSend()
if (pCert) {
return X509Certificate(pCert); }
else
throw SSLException("No certificate available yet");
} void SecureStreamSocketImpl::shutdown()
{
_impl.shutdown();
} } // namespace Poco::Net }
bool SecureStreamSocketImpl::secure() const
{
return true;
}
bool SecureStreamSocketImpl::havePeerCertificate() const
{
X509* pCert = _impl.peerCertificate();
if (pCert)
{
X509_free(pCert);
return true;
}
else return false;
}
X509Certificate SecureStreamSocketImpl::peerCertificate() const
{
X509* pCert = _impl.peerCertificate();
if (pCert)
return X509Certificate(pCert);
else
throw SSLException("No certificate available");
}
void SecureStreamSocketImpl::setLazyHandshake(bool flag)
{
_lazyHandshake = flag;
}
bool SecureStreamSocketImpl::getLazyHandshake() const
{
return _lazyHandshake;
}
void SecureStreamSocketImpl::verifyPeerCertificate()
{
_impl.verifyPeerCertificate();
}
void SecureStreamSocketImpl::verifyPeerCertificate(const std::string& hostName)
{
_impl.verifyPeerCertificate(hostName);
}
int SecureStreamSocketImpl::completeHandshake()
{
return _impl.completeHandshake();
}
} } // namespace Poco::Net

View File

@@ -0,0 +1,62 @@
//
// Session.cpp
//
// $Id: //poco/1.4/NetSSL_OpenSSL/src/Session.cpp#2 $
//
// Library: NetSSL_OpenSSL
// Package: SSLCore
// Module: Session
//
// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#if defined(__APPLE__)
// Some OpenSSL functions are deprecated in OS X 10.7
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include "Poco/Net/Session.h"
namespace Poco {
namespace Net {
Session::Session(SSL_SESSION* pSession):
_pSession(pSession)
{
}
Session::~Session()
{
SSL_SESSION_free(_pSession);
}
} } // namespace Poco::Net

View File

@@ -1,187 +1,195 @@
// //
// X509Certificate.cpp // X509Certificate.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/src/X509Certificate.cpp#14 $ // $Id: //poco/Main/NetSSL_OpenSSL/src/X509Certificate.cpp#14 $
// //
// Library: NetSSL_OpenSSL // Library: NetSSL_OpenSSL
// Package: SSLCore // Package: SSLCore
// Module: X509Certificate // Module: X509Certificate
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Net/X509Certificate.h" #include "Poco/Net/X509Certificate.h"
#include "Poco/Net/SSLException.h" #include "Poco/Net/SSLException.h"
#include "Poco/Net/SSLManager.h" #include "Poco/Net/SSLManager.h"
#include "Poco/Net/DNS.h" #include "Poco/Net/DNS.h"
#include "Poco/TemporaryFile.h" #include "Poco/TemporaryFile.h"
#include "Poco/FileStream.h" #include "Poco/FileStream.h"
#include "Poco/StreamCopier.h" #include "Poco/StreamCopier.h"
#include "Poco/String.h" #include "Poco/String.h"
#include "Poco/RegularExpression.h" #include "Poco/RegularExpression.h"
#include "Poco/DateTimeParser.h" #include "Poco/DateTimeParser.h"
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include <openssl/err.h> #include <openssl/err.h>
namespace Poco { namespace Poco {
namespace Net { namespace Net {
X509Certificate::X509Certificate(std::istream& istr): X509Certificate::X509Certificate(std::istream& istr):
Poco::Crypto::X509Certificate(istr) Poco::Crypto::X509Certificate(istr)
{ {
} }
X509Certificate::X509Certificate(const std::string& path): X509Certificate::X509Certificate(const std::string& path):
Poco::Crypto::X509Certificate(path) Poco::Crypto::X509Certificate(path)
{ {
} }
X509Certificate::X509Certificate(X509* pCert): X509Certificate::X509Certificate(X509* pCert):
Poco::Crypto::X509Certificate(pCert) Poco::Crypto::X509Certificate(pCert)
{ {
} }
X509Certificate::X509Certificate(const Poco::Crypto::X509Certificate& cert): X509Certificate::X509Certificate(X509* pCert, bool shared):
Poco::Crypto::X509Certificate(cert) Poco::Crypto::X509Certificate(pCert, shared)
{ {
} }
X509Certificate& X509Certificate::operator = (const Poco::Crypto::X509Certificate& cert) X509Certificate::X509Certificate(const Poco::Crypto::X509Certificate& cert):
{ Poco::Crypto::X509Certificate(cert)
X509Certificate tmp(cert); {
swap(tmp); }
return *this;
}
X509Certificate& X509Certificate::operator = (const Poco::Crypto::X509Certificate& cert)
{
X509Certificate::~X509Certificate() X509Certificate tmp(cert);
{ swap(tmp);
} return *this;
}
long X509Certificate::verify(const std::string& hostName) const
{ X509Certificate::~X509Certificate()
return verify(*this, hostName); {
} }
long X509Certificate::verify(const Poco::Crypto::X509Certificate& certificate, const std::string& hostName) bool X509Certificate::verify(const std::string& hostName) const
{ {
std::string commonName; return verify(*this, hostName);
std::set<std::string> dnsNames; }
certificate.extractNames(commonName, dnsNames);
bool ok = (dnsNames.find(hostName) != dnsNames.end());
bool X509Certificate::verify(const Poco::Crypto::X509Certificate& certificate, const std::string& hostName)
char buffer[NAME_BUFFER_SIZE]; {
X509_NAME* subj = 0; std::string commonName;
if (!ok && (subj = X509_get_subject_name(const_cast<X509*>(certificate.certificate()))) && X509_NAME_get_text_by_NID(subj, NID_commonName, buffer, sizeof(buffer)) > 0) std::set<std::string> dnsNames;
{ certificate.extractNames(commonName, dnsNames);
buffer[NAME_BUFFER_SIZE - 1] = 0; bool ok = (dnsNames.find(hostName) != dnsNames.end());
std::string commonName(buffer); // commonName can contain wildcards like *.appinf.com
try char buffer[NAME_BUFFER_SIZE];
{ X509_NAME* subj = 0;
// two cases: strData contains wildcards or not if (!ok && (subj = X509_get_subject_name(const_cast<X509*>(certificate.certificate()))) && X509_NAME_get_text_by_NID(subj, NID_commonName, buffer, sizeof(buffer)) > 0)
if (containsWildcards(commonName)) {
{ buffer[NAME_BUFFER_SIZE - 1] = 0;
// a compare by IPAddress is not possible with wildcards std::string commonName(buffer); // commonName can contain wildcards like *.appinf.com
// only allow compare by name try
const HostEntry& heData = DNS::resolve(hostName); {
ok = matchByAlias(commonName, heData); // two cases: strData contains wildcards or not
} if (containsWildcards(commonName))
else {
{ // a compare by IPAddress is not possible with wildcards
// it depends on hostName if we compare by IP or by alias // only allow compare by name
IPAddress ip; const HostEntry& heData = DNS::resolve(hostName);
if (IPAddress::tryParse(hostName, ip)) ok = matchByAlias(commonName, heData);
{ }
// compare by IP else
const HostEntry& heData = DNS::resolve(commonName); {
const HostEntry::AddressList& addr = heData.addresses(); // it depends on hostName if we compare by IP or by alias
HostEntry::AddressList::const_iterator it = addr.begin(); IPAddress ip;
HostEntry::AddressList::const_iterator itEnd = addr.end(); if (IPAddress::tryParse(hostName, ip))
for (; it != itEnd && !ok; ++it) {
{ // compare by IP
ok = (*it == ip); const HostEntry& heData = DNS::resolve(commonName);
} const HostEntry::AddressList& addr = heData.addresses();
} HostEntry::AddressList::const_iterator it = addr.begin();
else HostEntry::AddressList::const_iterator itEnd = addr.end();
{ for (; it != itEnd && !ok; ++it)
// compare by name {
const HostEntry& heData = DNS::resolve(hostName); ok = (*it == ip);
ok = matchByAlias(commonName, heData); }
} }
} else
} {
catch (HostNotFoundException&) // compare by name
{ const HostEntry& heData = DNS::resolve(hostName);
return X509_V_ERR_APPLICATION_VERIFICATION; ok = matchByAlias(commonName, heData);
} }
} }
}
// we already have a verify callback registered so no need to ask twice SSL_get_verify_result(pSSL); catch (HostNotFoundException&)
if (ok) {
return X509_V_OK; return false;
else }
return X509_V_ERR_APPLICATION_VERIFICATION; }
} return ok;
}
bool X509Certificate::containsWildcards(const std::string& commonName)
{ bool X509Certificate::containsWildcards(const std::string& commonName)
return (commonName.find('*') != std::string::npos || commonName.find('?') != std::string::npos); {
} return (commonName.find('*') != std::string::npos || commonName.find('?') != std::string::npos);
}
bool X509Certificate::matchByAlias(const std::string& alias, const HostEntry& heData)
{ bool X509Certificate::matchByAlias(const std::string& alias, const HostEntry& heData)
// fix wildcards {
std::string aliasRep = Poco::replace(alias, "*", ".*"); // fix wildcards
Poco::replaceInPlace(aliasRep, "..*", ".*"); std::string aliasRep = Poco::replace(alias, ".", "\\.");
Poco::replaceInPlace(aliasRep, "?", ".?"); Poco::replaceInPlace(aliasRep, "*", ".*");
Poco::replaceInPlace(aliasRep, "..?", ".?"); Poco::replaceInPlace(aliasRep, "..*", ".*");
// compare by name Poco::replaceInPlace(aliasRep, "?", ".?");
Poco::RegularExpression expr(aliasRep); Poco::replaceInPlace(aliasRep, "..?", ".?");
bool found = false; // compare by name
const HostEntry::AliasList& aliases = heData.aliases(); Poco::RegularExpression expr(aliasRep);
HostEntry::AliasList::const_iterator it = aliases.begin(); bool found = false;
HostEntry::AliasList::const_iterator itEnd = aliases.end(); const HostEntry::AliasList& aliases = heData.aliases();
for (; it != itEnd && !found; ++it) HostEntry::AliasList::const_iterator it = aliases.begin();
{ HostEntry::AliasList::const_iterator itEnd = aliases.end();
found = expr.match(*it); for (; it != itEnd && !found; ++it)
} {
return found; found = expr.match(*it);
} }
// Handle the case where the list of aliases is empty.
if (aliases.empty())
} } // namespace Poco::Net {
// Compare the host name against the wildcard host name in the certificate.
found = expr.match(heData.name());
}
return found;
}
} } // namespace Poco::Net

View File

@@ -1,42 +1,48 @@
<AppConfig> <AppConfig>
<openSSL> <openSSL>
<server> <server>
<privateKeyFile>${application.configDir}any.pem</privateKeyFile> <privateKeyFile>${application.configDir}any.pem</privateKeyFile>
<caConfig>${application.configDir}rootcert.pem</caConfig> <caConfig>${application.configDir}rootcert.pem</caConfig>
<verificationMode>none</verificationMode> <verificationMode>none</verificationMode>
<verificationDepth>9</verificationDepth> <verificationDepth>9</verificationDepth>
<loadDefaultCAFile>true</loadDefaultCAFile> <loadDefaultCAFile>true</loadDefaultCAFile>
<cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList> <cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList>
<privateKeyPassphraseHandler> <privateKeyPassphraseHandler>
<name>KeyFileHandler</name> <name>KeyFileHandler</name>
<options> <options>
<password>secret</password> <password>secret</password>
</options> </options>
</privateKeyPassphraseHandler> </privateKeyPassphraseHandler>
<invalidCertificateHandler> <invalidCertificateHandler>
<name>AcceptCertificateHandler</name> <name>AcceptCertificateHandler</name>
<options> <options>
</options> </options>
</invalidCertificateHandler> </invalidCertificateHandler>
</server> </server>
<client> <client>
<privateKeyFile>${application.configDir}any.pem</privateKeyFile> <privateKeyFile>${application.configDir}any.pem</privateKeyFile>
<caConfig>${application.configDir}rootcert.pem</caConfig> <caConfig>${application.configDir}rootcert.pem</caConfig>
<verificationMode>relaxed</verificationMode> <verificationMode>relaxed</verificationMode>
<verificationDepth>9</verificationDepth> <verificationDepth>9</verificationDepth>
<loadDefaultCAFile>true</loadDefaultCAFile> <loadDefaultCAFile>true</loadDefaultCAFile>
<cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList> <cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList>
<privateKeyPassphraseHandler> <privateKeyPassphraseHandler>
<name>KeyFileHandler</name> <name>KeyFileHandler</name>
<options> <options>
<password>secret</password> <password>secret</password>
</options> </options>
</privateKeyPassphraseHandler> </privateKeyPassphraseHandler>
<invalidCertificateHandler> <invalidCertificateHandler>
<name>AcceptCertificateHandler</name> <name>AcceptCertificateHandler</name>
<options> <options>
</options> </options>
</invalidCertificateHandler> </invalidCertificateHandler>
</client> </client>
</openSSL> </openSSL>
</AppConfig> <testsuite>
<proxy>
<host>proxy.aon.at</host>
<port>8080</port>
</proxy>
</testsuite>
</AppConfig>

View File

@@ -0,0 +1,327 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="debug_shared|Win32">
<Configuration>debug_shared</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_md|Win32">
<Configuration>debug_static_md</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_mt|Win32">
<Configuration>debug_static_mt</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_shared|Win32">
<Configuration>release_shared</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_md|Win32">
<Configuration>release_static_md</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_mt|Win32">
<Configuration>release_static_mt</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>TestSuite</ProjectName>
<ProjectGuid>{B2B88092-5BCE-4AC0-941E-88167138B4A7}</ProjectGuid>
<RootNamespace>TestSuite</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">bin\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">bin\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">bin\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">bin\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">false</LinkIncremental>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">TestSuite</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">TestSuite</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">TestSuite</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnitd.lib;WinTestRunnerd.lib;libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\TestSuited.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin\TestSuited.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnit.lib;WinTestRunner.lib;libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\TestSuite.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnitmtd.lib;WinTestRunnermtd.lib;iphlpapi.lib;winmm.lib;nafxcwd.lib;libcmtd.lib;WinTestRunner.res;libeay32mtd.lib;ssleay32mtd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_mt\TestSuited.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>nafxcwd.lib;libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin\static_mt\TestSuited.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnitmt.lib;WinTestRunnermt.lib;iphlpapi.lib;winmm.lib;nafxcw.lib;libcmt.lib;WinTestRunner.res;libeay32mt.lib;ssleay32mt.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_mt\TestSuite.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>nafxcw.lib;libcmt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnitmdd.lib;WinTestRunnermdd.lib;iphlpapi.lib;winmm.lib;WinTestRunner.res;libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_md\TestSuited.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin\static_md\TestSuited.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnitmd.lib;WinTestRunnermd.lib;iphlpapi.lib;winmm.lib;WinTestRunner.res;libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\static_md\TestSuite.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="src\HTTPSTestServer.h"/>
<ClInclude Include="src\NetSSLTestSuite.h"/>
<ClInclude Include="src\TCPServerTest.h"/>
<ClInclude Include="src\TCPServerTestSuite.h"/>
<ClInclude Include="src\HTTPSServerTest.h"/>
<ClInclude Include="src\HTTPSServerTestSuite.h"/>
<ClInclude Include="src\HTTPSClientSessionTest.h"/>
<ClInclude Include="src\HTTPSClientTestSuite.h"/>
<ClInclude Include="src\HTTPSStreamFactoryTest.h"/>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\HTTPSTestServer.cpp"/>
<ClCompile Include="src\NetSSLTestSuite.cpp"/>
<ClCompile Include="src\WinDriver.cpp"/>
<ClCompile Include="src\TCPServerTest.cpp"/>
<ClCompile Include="src\TCPServerTestSuite.cpp"/>
<ClCompile Include="src\HTTPSServerTest.cpp"/>
<ClCompile Include="src\HTTPSServerTestSuite.cpp"/>
<ClCompile Include="src\HTTPSClientSessionTest.cpp"/>
<ClCompile Include="src\HTTPSClientTestSuite.cpp"/>
<ClCompile Include="src\HTTPSStreamFactoryTest.cpp"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"/>
</Project>

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="HTTPS">
<UniqueIdentifier>{5895df5f-4143-4260-b683-e386cde3cff2}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPS\Header Files">
<UniqueIdentifier>{528d4bf7-ceb2-4f59-a60c-6c8dff658620}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPS\Source Files">
<UniqueIdentifier>{92f914f8-3034-4e8a-bb6f-ffc6df85d631}</UniqueIdentifier>
</Filter>
<Filter Include="_Suite">
<UniqueIdentifier>{ff5776a6-1180-4052-8da6-6a4ac9665e3a}</UniqueIdentifier>
</Filter>
<Filter Include="_Suite\Header Files">
<UniqueIdentifier>{6e598184-fe5a-47c9-a2cc-0dd04074224a}</UniqueIdentifier>
</Filter>
<Filter Include="_Suite\Source Files">
<UniqueIdentifier>{2bd4885f-8a91-4332-925f-6d433d619f11}</UniqueIdentifier>
</Filter>
<Filter Include="_Driver">
<UniqueIdentifier>{09d05d97-2fdf-4aff-a6b4-90dfce53e05f}</UniqueIdentifier>
</Filter>
<Filter Include="_Driver\Source Files">
<UniqueIdentifier>{3ebd1ab8-126b-497f-9cee-f37ab9f184d5}</UniqueIdentifier>
</Filter>
<Filter Include="TCPServer">
<UniqueIdentifier>{77dae20e-e3a9-4175-97e9-9b97edb08507}</UniqueIdentifier>
</Filter>
<Filter Include="TCPServer\Header Files">
<UniqueIdentifier>{d3ac07a4-484e-4109-9444-3c3d86da7e8f}</UniqueIdentifier>
</Filter>
<Filter Include="TCPServer\Source Files">
<UniqueIdentifier>{7c09e334-fe1e-4e3a-bbfd-41124384d638}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSServer">
<UniqueIdentifier>{9a124b21-907b-4c5b-9e5d-b9886d1cbcfb}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSServer\Header Files">
<UniqueIdentifier>{442aaca2-8047-4a39-af4d-5d304e8438ce}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSServer\Source Files">
<UniqueIdentifier>{b279c658-75ed-41d9-9c4f-3359cd58a58a}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient">
<UniqueIdentifier>{ef15cb54-7f4f-4f20-8122-d744f75abf4a}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient\Header Files">
<UniqueIdentifier>{d1800814-817a-4ccb-bd18-87da38e47493}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient\Source Files">
<UniqueIdentifier>{d4b01c3c-e317-4cea-8d6e-f87b27823918}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\HTTPSTestServer.h">
<Filter>HTTPS\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\NetSSLTestSuite.h">
<Filter>_Suite\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\TCPServerTest.h">
<Filter>TCPServer\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\TCPServerTestSuite.h">
<Filter>TCPServer\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HTTPSServerTest.h">
<Filter>HTTPSServer\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HTTPSServerTestSuite.h">
<Filter>HTTPSServer\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HTTPSClientSessionTest.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HTTPSClientTestSuite.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HTTPSStreamFactoryTest.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\HTTPSTestServer.cpp">
<Filter>HTTPS\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\NetSSLTestSuite.cpp">
<Filter>_Suite\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\WinDriver.cpp">
<Filter>_Driver\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\TCPServerTest.cpp">
<Filter>TCPServer\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\TCPServerTestSuite.cpp">
<Filter>TCPServer\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSServerTest.cpp">
<Filter>HTTPSServer\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSServerTestSuite.cpp">
<Filter>HTTPSServer\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSClientSessionTest.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSClientTestSuite.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSStreamFactoryTest.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -0,0 +1,327 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="debug_shared|x64">
<Configuration>debug_shared</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_md|x64">
<Configuration>debug_static_md</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug_static_mt|x64">
<Configuration>debug_static_mt</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_shared|x64">
<Configuration>release_shared</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_md|x64">
<Configuration>release_static_md</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release_static_mt|x64">
<Configuration>release_static_mt</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>TestSuite</ProjectName>
<ProjectGuid>{B2B88092-5BCE-4AC0-941E-88167138B4A7}</ProjectGuid>
<RootNamespace>TestSuite</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">bin64\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">bin64\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">bin64\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">bin64\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">false</LinkIncremental>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">TestSuite</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">TestSuite</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">TestSuite</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnitd.lib;WinTestRunnerd.lib;libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\TestSuited.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin64\TestSuited.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnit.lib;WinTestRunner.lib;libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\TestSuite.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnitmtd.lib;WinTestRunnermtd.lib;iphlpapi.lib;winmm.lib;nafxcwd.lib;libcmtd.lib;WinTestRunner.res;libeay32mtd.lib;ssleay32mtd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_mt\TestSuited.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>nafxcwd.lib;libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin64\static_mt\TestSuited.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnitmt.lib;WinTestRunnermt.lib;iphlpapi.lib;winmm.lib;nafxcw.lib;libcmt.lib;WinTestRunner.res;libeay32mt.lib;ssleay32mt.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_mt\TestSuite.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>nafxcw.lib;libcmt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnitmdd.lib;WinTestRunnermdd.lib;iphlpapi.lib;winmm.lib;WinTestRunner.res;libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_md\TestSuited.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin64\static_md\TestSuited.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\Net\include;..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat/>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>CppUnitmd.lib;WinTestRunnermd.lib;iphlpapi.lib;winmm.lib;WinTestRunner.res;libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin64\static_md\TestSuite.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="src\HTTPSTestServer.h"/>
<ClInclude Include="src\NetSSLTestSuite.h"/>
<ClInclude Include="src\TCPServerTest.h"/>
<ClInclude Include="src\TCPServerTestSuite.h"/>
<ClInclude Include="src\HTTPSServerTest.h"/>
<ClInclude Include="src\HTTPSServerTestSuite.h"/>
<ClInclude Include="src\HTTPSClientSessionTest.h"/>
<ClInclude Include="src\HTTPSClientTestSuite.h"/>
<ClInclude Include="src\HTTPSStreamFactoryTest.h"/>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\HTTPSTestServer.cpp"/>
<ClCompile Include="src\NetSSLTestSuite.cpp"/>
<ClCompile Include="src\WinDriver.cpp"/>
<ClCompile Include="src\TCPServerTest.cpp"/>
<ClCompile Include="src\TCPServerTestSuite.cpp"/>
<ClCompile Include="src\HTTPSServerTest.cpp"/>
<ClCompile Include="src\HTTPSServerTestSuite.cpp"/>
<ClCompile Include="src\HTTPSClientSessionTest.cpp"/>
<ClCompile Include="src\HTTPSClientTestSuite.cpp"/>
<ClCompile Include="src\HTTPSStreamFactoryTest.cpp"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"/>
</Project>

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="HTTPS">
<UniqueIdentifier>{41d8336b-ebbd-469a-a03a-5aa356c5f23c}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPS\Header Files">
<UniqueIdentifier>{13df473e-67e1-4714-8a3d-559e928455c8}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPS\Source Files">
<UniqueIdentifier>{70fa29b5-3949-4431-8636-1272e354d7db}</UniqueIdentifier>
</Filter>
<Filter Include="_Suite">
<UniqueIdentifier>{b9af60c8-11ee-4b67-b510-b36a5b364593}</UniqueIdentifier>
</Filter>
<Filter Include="_Suite\Header Files">
<UniqueIdentifier>{00f35a88-516d-4f97-9d46-0c203d68d5d5}</UniqueIdentifier>
</Filter>
<Filter Include="_Suite\Source Files">
<UniqueIdentifier>{b1a13cb4-059d-42a3-9201-f6369bcaeab9}</UniqueIdentifier>
</Filter>
<Filter Include="_Driver">
<UniqueIdentifier>{abba1fbc-a1ee-43f7-b00a-1fbf38b128b5}</UniqueIdentifier>
</Filter>
<Filter Include="_Driver\Source Files">
<UniqueIdentifier>{df0db81a-0dd7-44f1-af2d-d847c19f9d6a}</UniqueIdentifier>
</Filter>
<Filter Include="TCPServer">
<UniqueIdentifier>{7a3f38cf-0627-43c7-aaa3-227e49091562}</UniqueIdentifier>
</Filter>
<Filter Include="TCPServer\Header Files">
<UniqueIdentifier>{8c8100cc-ecd5-47ba-b37e-d0dd6b472b14}</UniqueIdentifier>
</Filter>
<Filter Include="TCPServer\Source Files">
<UniqueIdentifier>{a75ab1bf-3393-4396-b750-43de6352aadf}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSServer">
<UniqueIdentifier>{511eb615-3736-4365-a73c-57e5ebb9e4aa}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSServer\Header Files">
<UniqueIdentifier>{238f9c19-fc08-4caa-a944-ae4ac7e0535f}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSServer\Source Files">
<UniqueIdentifier>{5ab1bb74-2e2e-489e-8d63-bd6f3149f28f}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient">
<UniqueIdentifier>{ccc66b68-3941-4879-8aa8-a00e6d386e0e}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient\Header Files">
<UniqueIdentifier>{a05be5c6-8c90-4f80-94a0-7f55d3db2fd5}</UniqueIdentifier>
</Filter>
<Filter Include="HTTPSClient\Source Files">
<UniqueIdentifier>{7f0330d0-9a3f-4ec3-ae7c-6e78519e29df}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\HTTPSTestServer.h">
<Filter>HTTPS\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\NetSSLTestSuite.h">
<Filter>_Suite\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\TCPServerTest.h">
<Filter>TCPServer\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\TCPServerTestSuite.h">
<Filter>TCPServer\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HTTPSServerTest.h">
<Filter>HTTPSServer\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HTTPSServerTestSuite.h">
<Filter>HTTPSServer\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HTTPSClientSessionTest.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HTTPSClientTestSuite.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HTTPSStreamFactoryTest.h">
<Filter>HTTPSClient\Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\HTTPSTestServer.cpp">
<Filter>HTTPS\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\NetSSLTestSuite.cpp">
<Filter>_Suite\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\WinDriver.cpp">
<Filter>_Driver\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\TCPServerTest.cpp">
<Filter>TCPServer\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\TCPServerTestSuite.cpp">
<Filter>TCPServer\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSServerTest.cpp">
<Filter>HTTPSServer\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSServerTestSuite.cpp">
<Filter>HTTPSServer\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSClientSessionTest.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSClientTestSuite.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPSStreamFactoryTest.cpp">
<Filter>HTTPSClient\Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -0,0 +1,48 @@
<AppConfig>
<openSSL>
<server>
<privateKeyFile>${application.configDir}any.pem</privateKeyFile>
<caConfig>${application.configDir}rootcert.pem</caConfig>
<verificationMode>none</verificationMode>
<verificationDepth>9</verificationDepth>
<loadDefaultCAFile>true</loadDefaultCAFile>
<cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList>
<privateKeyPassphraseHandler>
<name>KeyFileHandler</name>
<options>
<password>secret</password>
</options>
</privateKeyPassphraseHandler>
<invalidCertificateHandler>
<name>AcceptCertificateHandler</name>
<options>
</options>
</invalidCertificateHandler>
</server>
<client>
<privateKeyFile>${application.configDir}any.pem</privateKeyFile>
<caConfig>${application.configDir}rootcert.pem</caConfig>
<verificationMode>relaxed</verificationMode>
<verificationDepth>9</verificationDepth>
<loadDefaultCAFile>true</loadDefaultCAFile>
<cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList>
<privateKeyPassphraseHandler>
<name>KeyFileHandler</name>
<options>
<password>secret</password>
</options>
</privateKeyPassphraseHandler>
<invalidCertificateHandler>
<name>AcceptCertificateHandler</name>
<options>
</options>
</invalidCertificateHandler>
</client>
</openSSL>
<testsuite>
<proxy>
<host>proxy.aon.at</host>
<port>8080</port>
</proxy>
</testsuite>
</AppConfig>

View File

@@ -1,54 +1,54 @@
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIEFjCCAv6gAwIBAgIBAjALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu MIIEFjCCAv6gAwIBAgIBAjALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu
Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n
aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh
cmludGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl cmludGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl
bnRhbDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu bnRhbDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu
Y29tMB4XDTA5MDIyMzEzNDIwMloXDTExMTEyMDEzNDIwMlowgcoxCjAIBgNVBAMM Y29tMB4XDTA5MDIyMzEzNDIwMloXDTExMTEyMDEzNDIwMlowgcoxCjAIBgNVBAMM
ASoxNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5naW5l ASoxNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5naW5l
ZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNhcmlu ZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNhcmlu
dGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3NlbnRh dGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3NlbnRh
bDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYuY29t bDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYuY29t
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxjGFE96wa83Kdiv0m10O MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxjGFE96wa83Kdiv0m10O
XmBmZ5xuclalVTCisLzUmAekbItMjkmI6dVw9r5gd0W5zDWrgPYUmYgtvqnxSHRK XmBmZ5xuclalVTCisLzUmAekbItMjkmI6dVw9r5gd0W5zDWrgPYUmYgtvqnxSHRK
PRAN410Yq9vqWYvQscpnXGlqUag8t+OBXJhiFnnea/btA0zGVZk6RE/7cWK8AtKH PRAN410Yq9vqWYvQscpnXGlqUag8t+OBXJhiFnnea/btA0zGVZk6RE/7cWK8AtKH
Q/Xds3AUJ1L/1uV/e/5azyUDyptsmHbCMUwWhGBrj/KZEviHmRMN/xJLrbIBPkla Q/Xds3AUJ1L/1uV/e/5azyUDyptsmHbCMUwWhGBrj/KZEviHmRMN/xJLrbIBPkla
4HRB61rI8in0jziCwThJ7KiQumzWRu2IJjS+VoNWvG52dYLDvfxppuY1rlF0SG/h 4HRB61rI8in0jziCwThJ7KiQumzWRu2IJjS+VoNWvG52dYLDvfxppuY1rlF0SG/h
JuSJQqJjZZ11V4TePHscFkGU2tnHqF4UhSjLFJWsGuxnAmZTeIRmavmIIMm3/G6C JuSJQqJjZZ11V4TePHscFkGU2tnHqF4UhSjLFJWsGuxnAmZTeIRmavmIIMm3/G6C
WwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQAc+mn/ZEaK59B/UAgx8cMlGM9UigJv WwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQAc+mn/ZEaK59B/UAgx8cMlGM9UigJv
L9O46pno3YirBq9SrMzf5b6rrbJm8tkQNfldqaVNA5oVbfxnAHhCUDkX8m0x/De8 L9O46pno3YirBq9SrMzf5b6rrbJm8tkQNfldqaVNA5oVbfxnAHhCUDkX8m0x/De8
teo9nFei8kETQ25ykV+WLapOdrYxakHPtNVgDTGWNb2GY/hH3nMvtdgFvaS80ncD teo9nFei8kETQ25ykV+WLapOdrYxakHPtNVgDTGWNb2GY/hH3nMvtdgFvaS80ncD
tOa13tE4jopFQFY56VKq+sv4Hm5JDvr+dD/g77Cio02sUzSH96FrFIG5/kw1NihB tOa13tE4jopFQFY56VKq+sv4Hm5JDvr+dD/g77Cio02sUzSH96FrFIG5/kw1NihB
IJKZ4n7atQizDe4TiR/NRonmZNbsB+18yTKT8traCS30JGKQqYxXuVKPyQd7FARv IJKZ4n7atQizDe4TiR/NRonmZNbsB+18yTKT8traCS30JGKQqYxXuVKPyQd7FARv
ajZxRPbcpAtvWBKXpRHXo4xIBJaPktVOG2hGovjRixXYb83hQ87t1Ozy ajZxRPbcpAtvWBKXpRHXo4xIBJaPktVOG2hGovjRixXYb83hQ87t1Ozy
-----END CERTIFICATE----- -----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,0950752701CB74AF DEK-Info: DES-EDE3-CBC,0950752701CB74AF
OmaLdMcP3JDy8JMX41wNH/WvMp6gLGwmqQRob633n95YxVdii0oR8fk4GgmJeYF0 OmaLdMcP3JDy8JMX41wNH/WvMp6gLGwmqQRob633n95YxVdii0oR8fk4GgmJeYF0
FrNm5g32vnVyqDZylX4as3GT822HhCA+f7mYpGZltQ47TG15tGTMUNuwIhHlouZs FrNm5g32vnVyqDZylX4as3GT822HhCA+f7mYpGZltQ47TG15tGTMUNuwIhHlouZs
ZGNclelBB3FHEZAD0Fns2hZ4jZhMDj67wD0YyGcp8so/A+fxedGdwNbJSC1Auuy4 ZGNclelBB3FHEZAD0Fns2hZ4jZhMDj67wD0YyGcp8so/A+fxedGdwNbJSC1Auuy4
7uRsY0ZJC1LjMHXkyBEXaL1QA4CGjBlm22Dbo8eoGXcaohsZpDsM7OU7MaQnldM0 7uRsY0ZJC1LjMHXkyBEXaL1QA4CGjBlm22Dbo8eoGXcaohsZpDsM7OU7MaQnldM0
AK8jONZ45127JoDJD41Wgfm0m7tIErsD5CbhHPaddOjQ0OerprEkplhOR+V+ano1 AK8jONZ45127JoDJD41Wgfm0m7tIErsD5CbhHPaddOjQ0OerprEkplhOR+V+ano1
Pv4adRZOBjr00NDB43WK9x+ZHVQ5tIXxUbqYWZAfvA1PpiYego5XLUCxfy7D6Lms Pv4adRZOBjr00NDB43WK9x+ZHVQ5tIXxUbqYWZAfvA1PpiYego5XLUCxfy7D6Lms
hV6CAt/fYeBrQOvwLREboKLBOe9A8quP2wi7zkR3KQHty9Tm9efF3PfQSxJTlKg9 hV6CAt/fYeBrQOvwLREboKLBOe9A8quP2wi7zkR3KQHty9Tm9efF3PfQSxJTlKg9
YJ2n/6omX1aXCjQghbnfEcl4tCmj6z2rHCSiJgEOcwDYhGRbQveYieZUH5iKMzYY YJ2n/6omX1aXCjQghbnfEcl4tCmj6z2rHCSiJgEOcwDYhGRbQveYieZUH5iKMzYY
YytHkHPfZfzhlJ0WG0AKdA6UlrjEjF09txaZR3Nj4Zf4kZAu727N81HnlFCRvDqV YytHkHPfZfzhlJ0WG0AKdA6UlrjEjF09txaZR3Nj4Zf4kZAu727N81HnlFCRvDqV
ZjHUrbE7fJuc3diffUfIHuQZuWcoYDejIbASjcJMHZOpbbPR2ZCYQqUmvg/IgAD6 ZjHUrbE7fJuc3diffUfIHuQZuWcoYDejIbASjcJMHZOpbbPR2ZCYQqUmvg/IgAD6
M2GDbvfvLnu1BaCrNMdOxM4j+sLNhm8qqAMxZ/wkZA9Sqhi2EifZwf5jWKNU3Vtx M2GDbvfvLnu1BaCrNMdOxM4j+sLNhm8qqAMxZ/wkZA9Sqhi2EifZwf5jWKNU3Vtx
C/w621efHawDME3WTMunDtjn7Sgm3NP508cz8OgcEcZLwENu8JH5pWR0Y0+qvlPM C/w621efHawDME3WTMunDtjn7Sgm3NP508cz8OgcEcZLwENu8JH5pWR0Y0+qvlPM
DYpCu2Zh6TBLU6Cfuxl2GigHHBhm8Eza/vE6dVbpyvEozejtVKi+RYskqz8ynYtl DYpCu2Zh6TBLU6Cfuxl2GigHHBhm8Eza/vE6dVbpyvEozejtVKi+RYskqz8ynYtl
r9NpDkEFcqGFLX/X7fajR4JxzxYx0Ms+CHHBlBLw44eMl1Izb9OBgfUK3a7wJ0Z1 r9NpDkEFcqGFLX/X7fajR4JxzxYx0Ms+CHHBlBLw44eMl1Izb9OBgfUK3a7wJ0Z1
vEmzcVtXZMqKDvqY3wddCcbtpVZhRnAUFgT3/b5ISxQ6xxFg67YQaJ0knuRwOZCI vEmzcVtXZMqKDvqY3wddCcbtpVZhRnAUFgT3/b5ISxQ6xxFg67YQaJ0knuRwOZCI
xSvNsxXb6s5xt8gRx8MY8W1CVW0QSH4gUpKdJFiF/6nYq7h8F1A5QYr34uJn5pa2 xSvNsxXb6s5xt8gRx8MY8W1CVW0QSH4gUpKdJFiF/6nYq7h8F1A5QYr34uJn5pa2
bsagCMhCUHKn/hrtTJ/4bC7n7utulXyEZJDGS38nNe5TBmAxeA+MkOAO7AEb8aDo bsagCMhCUHKn/hrtTJ/4bC7n7utulXyEZJDGS38nNe5TBmAxeA+MkOAO7AEb8aDo
RylaKT77tmeZXWBtlQGHj0bt2fPOEW3e0WUeNwk4qnKqSGdwbXGFK+yWxgGOxFDT RylaKT77tmeZXWBtlQGHj0bt2fPOEW3e0WUeNwk4qnKqSGdwbXGFK+yWxgGOxFDT
4NqUjDV7lhj1r3mKEufLIqP6GxAlewpH1uLA+ty2eNfG793pytlyhNikzmkliXex 4NqUjDV7lhj1r3mKEufLIqP6GxAlewpH1uLA+ty2eNfG793pytlyhNikzmkliXex
WnBUYQM6ZBclW0nALHxxOJWZlnBCESgo9lSHMeB7adJXuwaUmqHx4u+yNzaFS6pr WnBUYQM6ZBclW0nALHxxOJWZlnBCESgo9lSHMeB7adJXuwaUmqHx4u+yNzaFS6pr
LemBEUCHfLeGFM9E9YbgNe51q5+vXZYN5MZtqyex4AqPdGEGpwXBk43RK79mP84G LemBEUCHfLeGFM9E9YbgNe51q5+vXZYN5MZtqyex4AqPdGEGpwXBk43RK79mP84G
QQRAAcs6KMj1/Sl7pmg9acrxskLWljtsnvdCJ8a+VXjLDyp2wks1z2Gnw7cguZdD QQRAAcs6KMj1/Sl7pmg9acrxskLWljtsnvdCJ8a+VXjLDyp2wks1z2Gnw7cguZdD
Ah4hjH8LDTsEJxOr2DNJu/V9JDPKd0uGyaW0AOanwAn7tszivGddb/WrzImCIMBa Ah4hjH8LDTsEJxOr2DNJu/V9JDPKd0uGyaW0AOanwAn7tszivGddb/WrzImCIMBa
Lb/cqujvS9YsIK6xrq4LMxR5wE6Hol0qs6xO89Y9OpuuRxAYfRUl4nDTg0WjS5Ga Lb/cqujvS9YsIK6xrq4LMxR5wE6Hol0qs6xO89Y9OpuuRxAYfRUl4nDTg0WjS5Ga
0aoSXB0kOFkEwb3WGq+b26606RBYDKu7RsJoyWoXq42JZ1jkEYKCNeNS8hWh8GKd 0aoSXB0kOFkEwb3WGq+b26606RBYDKu7RsJoyWoXq42JZ1jkEYKCNeNS8hWh8GKd
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----

File diff suppressed because it is too large Load Diff

View File

@@ -1,84 +1,97 @@
// //
// Driver.cpp // Driver.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/Driver.cpp#10 $ // $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/Driver.cpp#10 $
// //
// Console-based test driver for Poco NetSSL. // Console-based test driver for Poco NetSSL.
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "CppUnit/TestRunner.h" #include "CppUnit/TestRunner.h"
#include "NetSSLTestSuite.h" #include "NetSSLTestSuite.h"
#include "Poco/Util/Application.h" #include "Poco/Util/Application.h"
#include "Poco/Net/HTTPStreamFactory.h" #include "Poco/Net/HTTPStreamFactory.h"
#include "Poco/Net/HTTPSStreamFactory.h" #include "Poco/Net/HTTPSStreamFactory.h"
#include <iostream> #include <iostream>
class NetSSLApp: public Poco::Util::Application class NetSSLApp: public Poco::Util::Application
{ {
public: public:
NetSSLApp() NetSSLApp()
{ {
} Poco::Net::initializeSSL();
Poco::Net::HTTPStreamFactory::registerFactory();
~NetSSLApp() Poco::Net::HTTPSStreamFactory::registerFactory();
{ }
}
~NetSSLApp()
protected: {
void initialize(Poco::Util::Application& self) Poco::Net::uninitializeSSL();
{ }
loadConfiguration(); // load default configuration files, if present
Poco::Util::Application::initialize(self); int main(const std::vector<std::string>& args)
} {
}; CppUnit::TestRunner runner;
runner.addTest("NetSSLTestSuite", NetSSLTestSuite::suite());
return runner.run(_targs) ? 0 : 1;
int main(int ac, char **av) }
{
Poco::Net::HTTPStreamFactory::registerFactory(); void setup(int argc, char** argv)
Poco::Net::HTTPSStreamFactory::registerFactory(); {
NetSSLApp app; init(1, argv);
try for (int i = 0; i < argc; ++i)
{ _targs.push_back(std::string(argv[i]));
app.init(1, av); }
}
catch (Poco::Exception& exc) protected:
{ void initialize(Poco::Util::Application& self)
std::cout << exc.displayText() << std::endl; {
return 1; loadConfiguration(); // load default configuration files, if present
} Poco::Util::Application::initialize(self);
}
std::vector<std::string> args;
for (int i = 0; i < ac; ++i) private:
args.push_back(std::string(av[i])); std::vector<std::string> _targs;
CppUnit::TestRunner runner; };
runner.addTest("NetSSLTestSuite", NetSSLTestSuite::suite());
return runner.run(args) ? 0 : 1;
} int main(int ac, char **av)
{
NetSSLApp app;
try
{
app.setup(ac, av);
return app.run();
}
catch (Poco::Exception& exc)
{
std::cout << exc.displayText() << std::endl;
return 1;
}
}

View File

@@ -1,363 +1,465 @@
// //
// HTTPSClientSessionTest.cpp // HTTPSClientSessionTest.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.cpp#10 $ // $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.cpp#10 $
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "HTTPSClientSessionTest.h" #include "HTTPSClientSessionTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Net/HTTPSClientSession.h" #include "Poco/Net/HTTPSClientSession.h"
#include "Poco/Net/HTTPRequest.h" #include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPRequestHandler.h" #include "Poco/Net/HTTPRequestHandler.h"
#include "Poco/Net/HTTPRequestHandlerFactory.h" #include "Poco/Net/HTTPRequestHandlerFactory.h"
#include "Poco/Net/HTTPResponse.h" #include "Poco/Net/HTTPResponse.h"
#include "Poco/Net/HTTPServer.h" #include "Poco/Net/HTTPServer.h"
#include "Poco/Net/HTTPServerResponse.h" #include "Poco/Net/HTTPServerResponse.h"
#include "Poco/Net/HTTPServerRequest.h" #include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/HTTPServerParams.h" #include "Poco/Net/HTTPServerParams.h"
#include "Poco/Net/SecureStreamSocket.h" #include "Poco/Net/SecureStreamSocket.h"
#include "Poco/StreamCopier.h" #include "Poco/Net/Context.h"
#include "Poco/Exception.h" #include "Poco/Net/Session.h"
#include "Poco/DateTimeFormatter.h" #include "Poco/Net/SSLManager.h"
#include "Poco/DateTimeFormat.h" #include "Poco/Util/Application.h"
#include "HTTPSTestServer.h" #include "Poco/Util/AbstractConfiguration.h"
#include <istream> #include "Poco/StreamCopier.h"
#include <ostream> #include "Poco/Exception.h"
#include <sstream> #include "Poco/DateTimeFormatter.h"
#include "Poco/DateTimeFormat.h"
#include "Poco/Thread.h"
using namespace Poco::Net; #include "HTTPSTestServer.h"
using Poco::StreamCopier; #include <istream>
#include <ostream>
#include <sstream>
class TestRequestHandler: public HTTPRequestHandler
/// Return a HTML document with the current date and time.
{ using namespace Poco::Net;
public: using Poco::Util::Application;
TestRequestHandler() using Poco::StreamCopier;
{ using Poco::Thread;
}
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) class TestRequestHandler: public HTTPRequestHandler
{ /// Return a HTML document with the current date and time.
response.setChunkedTransferEncoding(true); {
response.setContentType(request.getContentType()); public:
std::ostream& ostr = response.send(); TestRequestHandler()
Poco::StreamCopier::copyStream(request.stream(), ostr); {
} }
}; void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{
response.setChunkedTransferEncoding(true);
class TestRequestHandlerFactory: public HTTPRequestHandlerFactory response.setContentType(request.getContentType());
{ std::ostream& ostr = response.send();
public: Poco::StreamCopier::copyStream(request.stream(), ostr);
TestRequestHandlerFactory() }
{
} };
HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request)
{ class TestRequestHandlerFactory: public HTTPRequestHandlerFactory
return new TestRequestHandler(); {
} public:
}; TestRequestHandlerFactory()
{
}
HTTPSClientSessionTest::HTTPSClientSessionTest(const std::string& name): CppUnit::TestCase(name)
{ HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request)
} {
return new TestRequestHandler();
}
HTTPSClientSessionTest::~HTTPSClientSessionTest() };
{
}
HTTPSClientSessionTest::HTTPSClientSessionTest(const std::string& name): CppUnit::TestCase(name)
{
void HTTPSClientSessionTest::testGetSmall() }
{
HTTPSTestServer srv;
HTTPSClientSession s("localhost", srv.port()); HTTPSClientSessionTest::~HTTPSClientSessionTest()
HTTPRequest request(HTTPRequest::HTTP_GET, "/small"); {
s.sendRequest(request); }
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
assert (response.getContentLength() == HTTPSTestServer::SMALL_BODY.length()); void HTTPSClientSessionTest::testGetSmall()
assert (response.getContentType() == "text/plain"); {
std::ostringstream ostr; HTTPSTestServer srv;
StreamCopier::copyStream(rs, ostr); HTTPSClientSession s("localhost", srv.port());
assert (ostr.str() == HTTPSTestServer::SMALL_BODY); HTTPRequest request(HTTPRequest::HTTP_GET, "/small");
} s.sendRequest(request);
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
void HTTPSClientSessionTest::testGetLarge() assert (response.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
{ assert (response.getContentType() == "text/plain");
HTTPSTestServer srv; std::ostringstream ostr;
HTTPSClientSession s("localhost", srv.port()); StreamCopier::copyStream(rs, ostr);
HTTPRequest request(HTTPRequest::HTTP_GET, "/large"); assert (ostr.str() == HTTPSTestServer::SMALL_BODY);
s.sendRequest(request); }
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
assert (response.getContentLength() == HTTPSTestServer::LARGE_BODY.length()); void HTTPSClientSessionTest::testGetLarge()
assert (response.getContentType() == "text/plain"); {
std::ostringstream ostr; HTTPSTestServer srv;
StreamCopier::copyStream(rs, ostr); HTTPSClientSession s("localhost", srv.port());
assert (ostr.str() == HTTPSTestServer::LARGE_BODY); HTTPRequest request(HTTPRequest::HTTP_GET, "/large");
} s.sendRequest(request);
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
void HTTPSClientSessionTest::testHead() assert (response.getContentLength() == HTTPSTestServer::LARGE_BODY.length());
{ assert (response.getContentType() == "text/plain");
HTTPSTestServer srv; std::ostringstream ostr;
HTTPSClientSession s("localhost", srv.port()); StreamCopier::copyStream(rs, ostr);
HTTPRequest request(HTTPRequest::HTTP_HEAD, "/large"); assert (ostr.str() == HTTPSTestServer::LARGE_BODY);
s.sendRequest(request); }
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
assert (response.getContentLength() == HTTPSTestServer::LARGE_BODY.length()); void HTTPSClientSessionTest::testHead()
assert (response.getContentType() == "text/plain"); {
std::ostringstream ostr; HTTPSTestServer srv;
assert (StreamCopier::copyStream(rs, ostr) == 0); HTTPSClientSession s("localhost", srv.port());
} HTTPRequest request(HTTPRequest::HTTP_HEAD, "/large");
s.sendRequest(request);
HTTPResponse response;
void HTTPSClientSessionTest::testPostSmallIdentity() std::istream& rs = s.receiveResponse(response);
{ assert (response.getContentLength() == HTTPSTestServer::LARGE_BODY.length());
HTTPSTestServer srv; assert (response.getContentType() == "text/plain");
HTTPSClientSession s("localhost", srv.port()); std::ostringstream ostr;
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo"); assert (StreamCopier::copyStream(rs, ostr) == 0);
std::string body("this is a random request body\r\n0\r\n"); }
request.setContentLength((int) body.length());
s.sendRequest(request) << body;
HTTPResponse response; void HTTPSClientSessionTest::testPostSmallIdentity()
std::istream& rs = s.receiveResponse(response); {
assert (response.getContentLength() == body.length()); HTTPSTestServer srv;
std::ostringstream ostr; HTTPSClientSession s("localhost", srv.port());
StreamCopier::copyStream(rs, ostr); HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
assert (ostr.str() == body); std::string body("this is a random request body\r\n0\r\n");
} request.setContentLength((int) body.length());
s.sendRequest(request) << body;
HTTPResponse response;
void HTTPSClientSessionTest::testPostLargeIdentity() std::istream& rs = s.receiveResponse(response);
{ assert (response.getContentLength() == body.length());
HTTPSTestServer srv; std::ostringstream ostr;
HTTPSClientSession s("localhost", srv.port()); StreamCopier::copyStream(rs, ostr);
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo"); assert (ostr.str() == body);
std::string body(8000, 'x'); }
body.append("\r\n0\r\n");
request.setContentLength((int) body.length());
s.sendRequest(request) << body; void HTTPSClientSessionTest::testPostLargeIdentity()
HTTPResponse response; {
std::istream& rs = s.receiveResponse(response); HTTPSTestServer srv;
assert (response.getContentLength() == body.length()); HTTPSClientSession s("localhost", srv.port());
std::ostringstream ostr; HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
StreamCopier::copyStream(rs, ostr); std::string body(8000, 'x');
assert (ostr.str() == body); body.append("\r\n0\r\n");
} request.setContentLength((int) body.length());
s.sendRequest(request) << body;
HTTPResponse response;
void HTTPSClientSessionTest::testPostSmallChunked() std::istream& rs = s.receiveResponse(response);
{ assert (response.getContentLength() == body.length());
HTTPSTestServer srv; std::ostringstream ostr;
HTTPSClientSession s("localhost", srv.port()); StreamCopier::copyStream(rs, ostr);
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo"); assert (ostr.str() == body);
std::string body("this is a random request body"); }
request.setChunkedTransferEncoding(true);
s.sendRequest(request) << body;
HTTPResponse response; void HTTPSClientSessionTest::testPostSmallChunked()
std::istream& rs = s.receiveResponse(response); {
assert (response.getChunkedTransferEncoding()); HTTPSTestServer srv;
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH); HTTPSClientSession s("localhost", srv.port());
std::ostringstream ostr; HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
StreamCopier::copyStream(rs, ostr); std::string body("this is a random request body");
assert (ostr.str() == body); request.setChunkedTransferEncoding(true);
} s.sendRequest(request) << body;
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
void HTTPSClientSessionTest::testPostLargeChunked() assert (response.getChunkedTransferEncoding());
{ assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
HTTPSTestServer srv; std::ostringstream ostr;
HTTPSClientSession s("localhost", srv.port()); StreamCopier::copyStream(rs, ostr);
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo"); assert (ostr.str() == body);
std::string body(16000, 'x'); }
request.setChunkedTransferEncoding(true);
s.sendRequest(request) << body;
HTTPResponse response; void HTTPSClientSessionTest::testPostLargeChunked()
std::istream& rs = s.receiveResponse(response); {
assert (response.getChunkedTransferEncoding()); HTTPSTestServer srv;
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH); HTTPSClientSession s("localhost", srv.port());
std::ostringstream ostr; HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
StreamCopier::copyStream(rs, ostr); std::string body(16000, 'x');
assert (ostr.str() == body); request.setChunkedTransferEncoding(true);
} s.sendRequest(request) << body;
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
void HTTPSClientSessionTest::testPostLargeChunkedKeepAlive() assert (response.getChunkedTransferEncoding());
{ assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
SecureServerSocket svs(32322); std::ostringstream ostr;
HTTPServer srv(new TestRequestHandlerFactory(), svs, new HTTPServerParams()); StreamCopier::copyStream(rs, ostr);
srv.start(); assert (ostr.str() == body);
try }
{
HTTPSClientSession s("localhost", srv.port());
s.setKeepAlive(true); void HTTPSClientSessionTest::testPostLargeChunkedKeepAlive()
for (int i = 0; i < 10; ++i) {
{ SecureServerSocket svs(32322);
HTTPRequest request(HTTPRequest::HTTP_POST, "/keepAlive", HTTPMessage::HTTP_1_1); HTTPServer srv(new TestRequestHandlerFactory(), svs, new HTTPServerParams());
std::string body(16000, 'x'); srv.start();
request.setChunkedTransferEncoding(true); try
s.sendRequest(request) << body; {
HTTPResponse response; HTTPSClientSession s("localhost", srv.port());
std::istream& rs = s.receiveResponse(response); s.setKeepAlive(true);
assert (response.getChunkedTransferEncoding()); for (int i = 0; i < 10; ++i)
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH); {
std::ostringstream ostr; HTTPRequest request(HTTPRequest::HTTP_POST, "/keepAlive", HTTPMessage::HTTP_1_1);
StreamCopier::copyStream(rs, ostr); std::string body(16000, 'x');
assert (ostr.str() == body); request.setChunkedTransferEncoding(true);
} s.sendRequest(request) << body;
srv.stop(); HTTPResponse response;
} std::istream& rs = s.receiveResponse(response);
catch (...) assert (response.getChunkedTransferEncoding());
{ assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
srv.stop(); std::ostringstream ostr;
throw; StreamCopier::copyStream(rs, ostr);
} assert (ostr.str() == body);
} }
srv.stop();
}
void HTTPSClientSessionTest::testKeepAlive() catch (...)
{ {
HTTPSTestServer srv; srv.stop();
HTTPSClientSession s("localhost", srv.port()); throw;
s.setKeepAlive(true); }
HTTPRequest request(HTTPRequest::HTTP_HEAD, "/keepAlive", HTTPMessage::HTTP_1_1); }
s.sendRequest(request);
HTTPResponse response;
std::istream& rs1 = s.receiveResponse(response); void HTTPSClientSessionTest::testKeepAlive()
assert (response.getContentLength() == HTTPSTestServer::SMALL_BODY.length()); {
assert (response.getContentType() == "text/plain"); HTTPSTestServer srv;
assert (response.getKeepAlive()); HTTPSClientSession s("localhost", srv.port());
std::ostringstream ostr1; s.setKeepAlive(true);
assert (StreamCopier::copyStream(rs1, ostr1) == 0); HTTPRequest request(HTTPRequest::HTTP_HEAD, "/keepAlive", HTTPMessage::HTTP_1_1);
s.sendRequest(request);
request.setMethod(HTTPRequest::HTTP_GET); HTTPResponse response;
request.setURI("/small"); std::istream& rs1 = s.receiveResponse(response);
s.sendRequest(request); assert (response.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
std::istream& rs2 = s.receiveResponse(response); assert (response.getContentType() == "text/plain");
assert (response.getContentLength() == HTTPSTestServer::SMALL_BODY.length()); assert (response.getKeepAlive());
assert (response.getKeepAlive()); std::ostringstream ostr1;
std::ostringstream ostr2; assert (StreamCopier::copyStream(rs1, ostr1) == 0);
StreamCopier::copyStream(rs2, ostr2);
assert (ostr2.str() == HTTPSTestServer::SMALL_BODY); request.setMethod(HTTPRequest::HTTP_GET);
request.setURI("/small");
request.setMethod(HTTPRequest::HTTP_GET); s.sendRequest(request);
request.setURI("/large"); std::istream& rs2 = s.receiveResponse(response);
s.sendRequest(request); assert (response.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
std::istream& rs3 = s.receiveResponse(response); assert (response.getKeepAlive());
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH); std::ostringstream ostr2;
assert (response.getChunkedTransferEncoding()); StreamCopier::copyStream(rs2, ostr2);
assert (response.getKeepAlive()); assert (ostr2.str() == HTTPSTestServer::SMALL_BODY);
std::ostringstream ostr3;
int n = StreamCopier::copyStream(rs3, ostr3); request.setMethod(HTTPRequest::HTTP_GET);
assert (ostr3.str() == HTTPSTestServer::LARGE_BODY); request.setURI("/large");
s.sendRequest(request);
request.setMethod(HTTPRequest::HTTP_HEAD); std::istream& rs3 = s.receiveResponse(response);
request.setURI("/large"); assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
s.sendRequest(request); assert (response.getChunkedTransferEncoding());
std::istream& rs4= s.receiveResponse(response); assert (response.getKeepAlive());
assert (response.getContentLength() == HTTPSTestServer::LARGE_BODY.length()); std::ostringstream ostr3;
assert (response.getContentType() == "text/plain"); StreamCopier::copyStream(rs3, ostr3);
assert (!response.getKeepAlive()); assert (ostr3.str() == HTTPSTestServer::LARGE_BODY);
std::ostringstream ostr4;
assert (StreamCopier::copyStream(rs4, ostr4) == 0); request.setMethod(HTTPRequest::HTTP_HEAD);
} request.setURI("/large");
s.sendRequest(request);
std::istream& rs4 = s.receiveResponse(response);
void HTTPSClientSessionTest::testInterop() assert (response.getContentLength() == HTTPSTestServer::LARGE_BODY.length());
{ assert (response.getContentType() == "text/plain");
HTTPSClientSession s("secure.appinf.com"); assert (!response.getKeepAlive());
HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt"); std::ostringstream ostr4;
s.sendRequest(request); assert (StreamCopier::copyStream(rs4, ostr4) == 0);
X509Certificate cert = s.serverCertificate(); }
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
std::ostringstream ostr; void HTTPSClientSessionTest::testInterop()
StreamCopier::copyStream(rs, ostr); {
std::string str(ostr.str()); HTTPSClientSession s("secure.appinf.com");
assert (str == "This is a test file for NetSSL.\n"); HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt");
assert (cert.commonName() == "secure.appinf.com"); s.sendRequest(request);
} X509Certificate cert = s.serverCertificate();
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
void HTTPSClientSessionTest::testProxy() std::ostringstream ostr;
{ StreamCopier::copyStream(rs, ostr);
HTTPSTestServer srv; std::string str(ostr.str());
HTTPSClientSession s("secure.appinf.com"); assert (str == "This is a test file for NetSSL.\n");
s.setProxy("proxy.aon.at", 8080); assert (cert.commonName() == "secure.appinf.com");
HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt"); }
s.sendRequest(request);
X509Certificate cert = s.serverCertificate();
HTTPResponse response; void HTTPSClientSessionTest::testProxy()
std::istream& rs = s.receiveResponse(response); {
std::ostringstream ostr; HTTPSTestServer srv;
StreamCopier::copyStream(rs, ostr); HTTPSClientSession s("secure.appinf.com");
std::string str(ostr.str()); s.setProxy(
assert (str == "This is a test file for NetSSL.\n"); Application::instance().config().getString("testsuite.proxy.host"),
assert (cert.commonName() == "secure.appinf.com"); Application::instance().config().getInt("testsuite.proxy.port")
} );
HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt");
s.sendRequest(request);
void HTTPSClientSessionTest::setUp() X509Certificate cert = s.serverCertificate();
{ HTTPResponse response;
} std::istream& rs = s.receiveResponse(response);
std::ostringstream ostr;
StreamCopier::copyStream(rs, ostr);
void HTTPSClientSessionTest::tearDown() std::string str(ostr.str());
{ assert (str == "This is a test file for NetSSL.\n");
} assert (cert.commonName() == "secure.appinf.com");
}
CppUnit::Test* HTTPSClientSessionTest::suite()
{ void HTTPSClientSessionTest::testCachedSession()
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("HTTPSClientSessionTest"); {
// ensure OpenSSL machinery is fully setup
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testGetSmall); Context::Ptr pDefaultServerContext = SSLManager::instance().defaultServerContext();
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testGetLarge); Context::Ptr pDefaultClientContext = SSLManager::instance().defaultClientContext();
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testHead);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostSmallIdentity); Context::Ptr pServerContext = new Context(
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeIdentity); Context::SERVER_USE,
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostSmallChunked); Application::instance().config().getString("openSSL.server.privateKeyFile"),
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeChunked); Application::instance().config().getString("openSSL.server.privateKeyFile"),
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeChunkedKeepAlive); Application::instance().config().getString("openSSL.server.caConfig"),
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testKeepAlive); Context::VERIFY_NONE,
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testInterop); 9,
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testProxy); true,
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
return pSuite; pServerContext->enableSessionCache(true, "TestSuite");
} pServerContext->setSessionTimeout(10);
pServerContext->setSessionCacheSize(1000);
pServerContext->disableStatelessSessionResumption();
HTTPSTestServer srv(pServerContext);
Context::Ptr pClientContext = new Context(
Context::CLIENT_USE,
Application::instance().config().getString("openSSL.client.privateKeyFile"),
Application::instance().config().getString("openSSL.client.privateKeyFile"),
Application::instance().config().getString("openSSL.client.caConfig"),
Context::VERIFY_RELAXED,
9,
true,
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
pClientContext->enableSessionCache(true);
HTTPSClientSession s1("localhost", srv.port(), pClientContext);
HTTPRequest request1(HTTPRequest::HTTP_GET, "/small");
s1.sendRequest(request1);
Session::Ptr pSession1 = s1.sslSession();
HTTPResponse response1;
std::istream& rs1 = s1.receiveResponse(response1);
assert (response1.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
assert (response1.getContentType() == "text/plain");
std::ostringstream ostr1;
StreamCopier::copyStream(rs1, ostr1);
assert (ostr1.str() == HTTPSTestServer::SMALL_BODY);
HTTPSClientSession s2("localhost", srv.port(), pClientContext, pSession1);
HTTPRequest request2(HTTPRequest::HTTP_GET, "/small");
s2.sendRequest(request2);
Session::Ptr pSession2 = s2.sslSession();
HTTPResponse response2;
std::istream& rs2 = s2.receiveResponse(response2);
assert (response2.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
assert (response2.getContentType() == "text/plain");
std::ostringstream ostr2;
StreamCopier::copyStream(rs2, ostr2);
assert (ostr2.str() == HTTPSTestServer::SMALL_BODY);
assert (pSession1 == pSession2);
HTTPRequest request3(HTTPRequest::HTTP_GET, "/small");
s2.sendRequest(request3);
Session::Ptr pSession3 = s2.sslSession();
HTTPResponse response3;
std::istream& rs3 = s2.receiveResponse(response3);
assert (response3.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
assert (response3.getContentType() == "text/plain");
std::ostringstream ostr3;
StreamCopier::copyStream(rs3, ostr3);
assert (ostr3.str() == HTTPSTestServer::SMALL_BODY);
assert (pSession1 == pSession3);
Thread::sleep(15000); // wait for session to expire
pServerContext->flushSessionCache();
HTTPRequest request4(HTTPRequest::HTTP_GET, "/small");
s2.sendRequest(request4);
Session::Ptr pSession4 = s2.sslSession();
HTTPResponse response4;
std::istream& rs4 = s2.receiveResponse(response4);
assert (response4.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
assert (response4.getContentType() == "text/plain");
std::ostringstream ostr4;
StreamCopier::copyStream(rs4, ostr4);
assert (ostr4.str() == HTTPSTestServer::SMALL_BODY);
assert (pSession1 != pSession4);
}
void HTTPSClientSessionTest::setUp()
{
}
void HTTPSClientSessionTest::tearDown()
{
}
CppUnit::Test* HTTPSClientSessionTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("HTTPSClientSessionTest");
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testGetSmall);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testGetLarge);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testHead);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostSmallIdentity);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeIdentity);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostSmallChunked);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeChunked);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeChunkedKeepAlive);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testKeepAlive);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testInterop);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testProxy);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testCachedSession);
return pSuite;
}

View File

@@ -1,70 +1,71 @@
// //
// HTTPSClientSessionTest.h // HTTPSClientSessionTest.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.h#10 $ // $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.h#10 $
// //
// Definition of the HTTPSClientSessionTest class. // Definition of the HTTPSClientSessionTest class.
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef HTTPSClientSessionTest_INCLUDED #ifndef HTTPSClientSessionTest_INCLUDED
#define HTTPSClientSessionTest_INCLUDED #define HTTPSClientSessionTest_INCLUDED
#include "Poco/Net/Net.h" #include "Poco/Net/Net.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
class HTTPSClientSessionTest: public CppUnit::TestCase class HTTPSClientSessionTest: public CppUnit::TestCase
{ {
public: public:
HTTPSClientSessionTest(const std::string& name); HTTPSClientSessionTest(const std::string& name);
~HTTPSClientSessionTest(); ~HTTPSClientSessionTest();
void testGetSmall(); void testGetSmall();
void testGetLarge(); void testGetLarge();
void testHead(); void testHead();
void testPostSmallIdentity(); void testPostSmallIdentity();
void testPostLargeIdentity(); void testPostLargeIdentity();
void testPostSmallChunked(); void testPostSmallChunked();
void testPostLargeChunked(); void testPostLargeChunked();
void testPostLargeChunkedKeepAlive(); void testPostLargeChunkedKeepAlive();
void testKeepAlive(); void testKeepAlive();
void testInterop(); void testInterop();
void testProxy(); void testProxy();
void testCachedSession();
void setUp();
void tearDown(); void setUp();
void tearDown();
static CppUnit::Test* suite();
static CppUnit::Test* suite();
private:
}; private:
};
#endif // HTTPSClientSessionTest_INCLUDED
#endif // HTTPSClientSessionTest_INCLUDED

View File

@@ -1,371 +1,371 @@
// //
// HTTPSServerTest.cpp // HTTPSServerTest.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSServerTest.cpp#9 $ // $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSServerTest.cpp#9 $
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "HTTPSServerTest.h" #include "HTTPSServerTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Net/HTTPServer.h" #include "Poco/Net/HTTPServer.h"
#include "Poco/Net/HTTPServerParams.h" #include "Poco/Net/HTTPServerParams.h"
#include "Poco/Net/HTTPRequestHandler.h" #include "Poco/Net/HTTPRequestHandler.h"
#include "Poco/Net/HTTPRequestHandlerFactory.h" #include "Poco/Net/HTTPRequestHandlerFactory.h"
#include "Poco/Net/HTTPSClientSession.h" #include "Poco/Net/HTTPSClientSession.h"
#include "Poco/Net/HTTPRequest.h" #include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPServerRequest.h" #include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/HTTPResponse.h" #include "Poco/Net/HTTPResponse.h"
#include "Poco/Net/HTTPServerResponse.h" #include "Poco/Net/HTTPServerResponse.h"
#include "Poco/Net/SecureServerSocket.h" #include "Poco/Net/SecureServerSocket.h"
#include "Poco/StreamCopier.h" #include "Poco/StreamCopier.h"
#include <sstream> #include <sstream>
using Poco::Net::HTTPServer; using Poco::Net::HTTPServer;
using Poco::Net::HTTPServerParams; using Poco::Net::HTTPServerParams;
using Poco::Net::HTTPRequestHandler; using Poco::Net::HTTPRequestHandler;
using Poco::Net::HTTPRequestHandlerFactory; using Poco::Net::HTTPRequestHandlerFactory;
using Poco::Net::HTTPSClientSession; using Poco::Net::HTTPSClientSession;
using Poco::Net::HTTPRequest; using Poco::Net::HTTPRequest;
using Poco::Net::HTTPServerRequest; using Poco::Net::HTTPServerRequest;
using Poco::Net::HTTPResponse; using Poco::Net::HTTPResponse;
using Poco::Net::HTTPServerResponse; using Poco::Net::HTTPServerResponse;
using Poco::Net::HTTPMessage; using Poco::Net::HTTPMessage;
using Poco::Net::SecureServerSocket; using Poco::Net::SecureServerSocket;
using Poco::StreamCopier; using Poco::StreamCopier;
namespace namespace
{ {
class EchoBodyRequestHandler: public HTTPRequestHandler class EchoBodyRequestHandler: public HTTPRequestHandler
{ {
public: public:
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{ {
if (request.getChunkedTransferEncoding()) if (request.getChunkedTransferEncoding())
response.setChunkedTransferEncoding(true); response.setChunkedTransferEncoding(true);
else if (request.getContentLength() != HTTPMessage::UNKNOWN_CONTENT_LENGTH) else if (request.getContentLength() != HTTPMessage::UNKNOWN_CONTENT_LENGTH)
response.setContentLength(request.getContentLength()); response.setContentLength(request.getContentLength());
response.setContentType(request.getContentType()); response.setContentType(request.getContentType());
std::istream& istr = request.stream(); std::istream& istr = request.stream();
std::ostream& ostr = response.send(); std::ostream& ostr = response.send();
int n = StreamCopier::copyStream(istr, ostr); StreamCopier::copyStream(istr, ostr);
} }
}; };
class EchoHeaderRequestHandler: public HTTPRequestHandler class EchoHeaderRequestHandler: public HTTPRequestHandler
{ {
public: public:
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{ {
std::ostringstream osstr; std::ostringstream osstr;
request.write(osstr); request.write(osstr);
int n = (int) osstr.str().length(); int n = (int) osstr.str().length();
response.setContentLength(n); response.setContentLength(n);
std::ostream& ostr = response.send(); std::ostream& ostr = response.send();
if (request.getMethod() != HTTPRequest::HTTP_HEAD) if (request.getMethod() != HTTPRequest::HTTP_HEAD)
request.write(ostr); request.write(ostr);
} }
}; };
class RedirectRequestHandler: public HTTPRequestHandler class RedirectRequestHandler: public HTTPRequestHandler
{ {
public: public:
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{ {
response.redirect("http://www.appinf.com/"); response.redirect("http://www.appinf.com/");
} }
}; };
class AuthRequestHandler: public HTTPRequestHandler class AuthRequestHandler: public HTTPRequestHandler
{ {
public: public:
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{ {
response.requireAuthentication("/auth"); response.requireAuthentication("/auth");
response.send(); response.send();
} }
}; };
class RequestHandlerFactory: public HTTPRequestHandlerFactory class RequestHandlerFactory: public HTTPRequestHandlerFactory
{ {
public: public:
HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request) HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request)
{ {
if (request.getURI() == "/echoBody") if (request.getURI() == "/echoBody")
return new EchoBodyRequestHandler; return new EchoBodyRequestHandler;
else if (request.getURI() == "/echoHeader") else if (request.getURI() == "/echoHeader")
return new EchoHeaderRequestHandler; return new EchoHeaderRequestHandler;
else if (request.getURI() == "/redirect") else if (request.getURI() == "/redirect")
return new RedirectRequestHandler(); return new RedirectRequestHandler();
else if (request.getURI() == "/auth") else if (request.getURI() == "/auth")
return new AuthRequestHandler(); return new AuthRequestHandler();
else else
return 0; return 0;
} }
}; };
} }
HTTPSServerTest::HTTPSServerTest(const std::string& name): CppUnit::TestCase(name) HTTPSServerTest::HTTPSServerTest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
HTTPSServerTest::~HTTPSServerTest() HTTPSServerTest::~HTTPSServerTest()
{ {
} }
void HTTPSServerTest::testIdentityRequest() void HTTPSServerTest::testIdentityRequest()
{ {
SecureServerSocket svs(0); SecureServerSocket svs(0);
HTTPServerParams* pParams = new HTTPServerParams; HTTPServerParams* pParams = new HTTPServerParams;
pParams->setKeepAlive(false); pParams->setKeepAlive(false);
HTTPServer srv(new RequestHandlerFactory, svs, pParams); HTTPServer srv(new RequestHandlerFactory, svs, pParams);
srv.start(); srv.start();
HTTPSClientSession cs("localhost", svs.address().port()); HTTPSClientSession cs("localhost", svs.address().port());
std::string body(5000, 'x'); std::string body(5000, 'x');
HTTPRequest request("POST", "/echoBody"); HTTPRequest request("POST", "/echoBody");
request.setContentLength((int) body.length()); request.setContentLength((int) body.length());
request.setContentType("text/plain"); request.setContentType("text/plain");
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
HTTPResponse response; HTTPResponse response;
std::string rbody; std::string rbody;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getContentLength() == body.size()); assert (response.getContentLength() == body.size());
assert (response.getContentType() == "text/plain"); assert (response.getContentType() == "text/plain");
assert (rbody == body); assert (rbody == body);
} }
void HTTPSServerTest::testChunkedRequest() void HTTPSServerTest::testChunkedRequest()
{ {
SecureServerSocket svs(0); SecureServerSocket svs(0);
HTTPServerParams* pParams = new HTTPServerParams; HTTPServerParams* pParams = new HTTPServerParams;
pParams->setKeepAlive(false); pParams->setKeepAlive(false);
HTTPServer srv(new RequestHandlerFactory, svs, pParams); HTTPServer srv(new RequestHandlerFactory, svs, pParams);
srv.start(); srv.start();
HTTPSClientSession cs("localhost", svs.address().port()); HTTPSClientSession cs("localhost", svs.address().port());
std::string body(5000, 'x'); std::string body(5000, 'x');
HTTPRequest request("POST", "/echoBody"); HTTPRequest request("POST", "/echoBody");
request.setContentType("text/plain"); request.setContentType("text/plain");
request.setChunkedTransferEncoding(true); request.setChunkedTransferEncoding(true);
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
HTTPResponse response; HTTPResponse response;
std::string rbody; std::string rbody;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH); assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
assert (response.getContentType() == "text/plain"); assert (response.getContentType() == "text/plain");
assert (response.getChunkedTransferEncoding()); assert (response.getChunkedTransferEncoding());
assert (rbody == body); assert (rbody == body);
} }
void HTTPSServerTest::testIdentityRequestKeepAlive() void HTTPSServerTest::testIdentityRequestKeepAlive()
{ {
SecureServerSocket svs(0); SecureServerSocket svs(0);
HTTPServerParams* pParams = new HTTPServerParams; HTTPServerParams* pParams = new HTTPServerParams;
pParams->setKeepAlive(true); pParams->setKeepAlive(true);
HTTPServer srv(new RequestHandlerFactory, svs, pParams); HTTPServer srv(new RequestHandlerFactory, svs, pParams);
srv.start(); srv.start();
HTTPSClientSession cs("localhost", svs.address().port()); HTTPSClientSession cs("localhost", svs.address().port());
cs.setKeepAlive(true); cs.setKeepAlive(true);
std::string body(5000, 'x'); std::string body(5000, 'x');
HTTPRequest request("POST", "/echoBody", HTTPMessage::HTTP_1_1); HTTPRequest request("POST", "/echoBody", HTTPMessage::HTTP_1_1);
request.setContentLength((int) body.length()); request.setContentLength((int) body.length());
request.setContentType("text/plain"); request.setContentType("text/plain");
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
HTTPResponse response; HTTPResponse response;
std::string rbody; std::string rbody;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getContentLength() == body.size()); assert (response.getContentLength() == body.size());
assert (response.getContentType() == "text/plain"); assert (response.getContentType() == "text/plain");
assert (response.getKeepAlive()); assert (response.getKeepAlive());
assert (rbody == body); assert (rbody == body);
body.assign(1000, 'y'); body.assign(1000, 'y');
request.setContentLength((int) body.length()); request.setContentLength((int) body.length());
request.setKeepAlive(false); request.setKeepAlive(false);
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getContentLength() == body.size()); assert (response.getContentLength() == body.size());
assert (response.getContentType() == "text/plain"); assert (response.getContentType() == "text/plain");
assert (!response.getKeepAlive()); assert (!response.getKeepAlive());
assert (rbody == body);} assert (rbody == body);}
void HTTPSServerTest::testChunkedRequestKeepAlive() void HTTPSServerTest::testChunkedRequestKeepAlive()
{ {
SecureServerSocket svs(0); SecureServerSocket svs(0);
HTTPServerParams* pParams = new HTTPServerParams; HTTPServerParams* pParams = new HTTPServerParams;
pParams->setKeepAlive(true); pParams->setKeepAlive(true);
HTTPServer srv(new RequestHandlerFactory, svs, pParams); HTTPServer srv(new RequestHandlerFactory, svs, pParams);
srv.start(); srv.start();
HTTPSClientSession cs("localhost", svs.address().port()); HTTPSClientSession cs("localhost", svs.address().port());
cs.setKeepAlive(true); cs.setKeepAlive(true);
std::string body(5000, 'x'); std::string body(5000, 'x');
HTTPRequest request("POST", "/echoBody", HTTPMessage::HTTP_1_1); HTTPRequest request("POST", "/echoBody", HTTPMessage::HTTP_1_1);
request.setContentType("text/plain"); request.setContentType("text/plain");
request.setChunkedTransferEncoding(true); request.setChunkedTransferEncoding(true);
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
HTTPResponse response; HTTPResponse response;
std::string rbody; std::string rbody;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH); assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
assert (response.getContentType() == "text/plain"); assert (response.getContentType() == "text/plain");
assert (response.getChunkedTransferEncoding()); assert (response.getChunkedTransferEncoding());
assert (rbody == body); assert (rbody == body);
body.assign(1000, 'y'); body.assign(1000, 'y');
request.setKeepAlive(false); request.setKeepAlive(false);
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH); assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
assert (response.getContentType() == "text/plain"); assert (response.getContentType() == "text/plain");
assert (response.getChunkedTransferEncoding()); assert (response.getChunkedTransferEncoding());
assert (!response.getKeepAlive()); assert (!response.getKeepAlive());
assert (rbody == body); assert (rbody == body);
} }
void HTTPSServerTest::test100Continue() void HTTPSServerTest::test100Continue()
{ {
SecureServerSocket svs(0); SecureServerSocket svs(0);
HTTPServerParams* pParams = new HTTPServerParams; HTTPServerParams* pParams = new HTTPServerParams;
pParams->setKeepAlive(false); pParams->setKeepAlive(false);
HTTPServer srv(new RequestHandlerFactory, svs, pParams); HTTPServer srv(new RequestHandlerFactory, svs, pParams);
srv.start(); srv.start();
HTTPSClientSession cs("localhost", svs.address().port()); HTTPSClientSession cs("localhost", svs.address().port());
std::string body(5000, 'x'); std::string body(5000, 'x');
HTTPRequest request("POST", "/echoBody"); HTTPRequest request("POST", "/echoBody");
request.setContentLength((int) body.length()); request.setContentLength((int) body.length());
request.setContentType("text/plain"); request.setContentType("text/plain");
request.set("Expect", "100-Continue"); request.set("Expect", "100-Continue");
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
HTTPResponse response; HTTPResponse response;
std::string rbody; std::string rbody;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getContentLength() == body.size()); assert (response.getContentLength() == body.size());
assert (response.getContentType() == "text/plain"); assert (response.getContentType() == "text/plain");
assert (rbody == body); assert (rbody == body);
} }
void HTTPSServerTest::testRedirect() void HTTPSServerTest::testRedirect()
{ {
SecureServerSocket svs(0); SecureServerSocket svs(0);
HTTPServerParams* pParams = new HTTPServerParams; HTTPServerParams* pParams = new HTTPServerParams;
pParams->setKeepAlive(false); pParams->setKeepAlive(false);
HTTPServer srv(new RequestHandlerFactory, svs, pParams); HTTPServer srv(new RequestHandlerFactory, svs, pParams);
srv.start(); srv.start();
HTTPSClientSession cs("localhost", svs.address().port()); HTTPSClientSession cs("localhost", svs.address().port());
HTTPRequest request("GET", "/redirect"); HTTPRequest request("GET", "/redirect");
cs.sendRequest(request); cs.sendRequest(request);
HTTPResponse response; HTTPResponse response;
std::string rbody; std::string rbody;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getStatus() == HTTPResponse::HTTP_FOUND); assert (response.getStatus() == HTTPResponse::HTTP_FOUND);
assert (response.get("Location") == "http://www.appinf.com/"); assert (response.get("Location") == "http://www.appinf.com/");
assert (rbody.empty()); assert (rbody.empty());
} }
void HTTPSServerTest::testAuth() void HTTPSServerTest::testAuth()
{ {
SecureServerSocket svs(0); SecureServerSocket svs(0);
HTTPServerParams* pParams = new HTTPServerParams; HTTPServerParams* pParams = new HTTPServerParams;
pParams->setKeepAlive(false); pParams->setKeepAlive(false);
HTTPServer srv(new RequestHandlerFactory, svs, pParams); HTTPServer srv(new RequestHandlerFactory, svs, pParams);
srv.start(); srv.start();
HTTPSClientSession cs("localhost", svs.address().port()); HTTPSClientSession cs("localhost", svs.address().port());
HTTPRequest request("GET", "/auth"); HTTPRequest request("GET", "/auth");
cs.sendRequest(request); cs.sendRequest(request);
HTTPResponse response; HTTPResponse response;
std::string rbody; std::string rbody;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getStatus() == HTTPResponse::HTTP_UNAUTHORIZED); assert (response.getStatus() == HTTPResponse::HTTP_UNAUTHORIZED);
assert (response.get("WWW-Authenticate") == "Basic realm=\"/auth\""); assert (response.get("WWW-Authenticate") == "Basic realm=\"/auth\"");
assert (rbody.empty()); assert (rbody.empty());
} }
void HTTPSServerTest::testNotImpl() void HTTPSServerTest::testNotImpl()
{ {
SecureServerSocket svs(0); SecureServerSocket svs(0);
HTTPServerParams* pParams = new HTTPServerParams; HTTPServerParams* pParams = new HTTPServerParams;
pParams->setKeepAlive(false); pParams->setKeepAlive(false);
HTTPServer srv(new RequestHandlerFactory, svs, pParams); HTTPServer srv(new RequestHandlerFactory, svs, pParams);
srv.start(); srv.start();
HTTPSClientSession cs("localhost", svs.address().port()); HTTPSClientSession cs("localhost", svs.address().port());
HTTPRequest request("GET", "/notImpl"); HTTPRequest request("GET", "/notImpl");
cs.sendRequest(request); cs.sendRequest(request);
HTTPResponse response; HTTPResponse response;
std::string rbody; std::string rbody;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getStatus() == HTTPResponse::HTTP_NOT_IMPLEMENTED); assert (response.getStatus() == HTTPResponse::HTTP_NOT_IMPLEMENTED);
assert (rbody.empty()); assert (rbody.empty());
} }
void HTTPSServerTest::setUp() void HTTPSServerTest::setUp()
{ {
} }
void HTTPSServerTest::tearDown() void HTTPSServerTest::tearDown()
{ {
} }
CppUnit::Test* HTTPSServerTest::suite() CppUnit::Test* HTTPSServerTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("HTTPSServerTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("HTTPSServerTest");
CppUnit_addTest(pSuite, HTTPSServerTest, testIdentityRequest); CppUnit_addTest(pSuite, HTTPSServerTest, testIdentityRequest);
CppUnit_addTest(pSuite, HTTPSServerTest, testChunkedRequest); CppUnit_addTest(pSuite, HTTPSServerTest, testChunkedRequest);
CppUnit_addTest(pSuite, HTTPSServerTest, testIdentityRequestKeepAlive); CppUnit_addTest(pSuite, HTTPSServerTest, testIdentityRequestKeepAlive);
CppUnit_addTest(pSuite, HTTPSServerTest, testChunkedRequestKeepAlive); CppUnit_addTest(pSuite, HTTPSServerTest, testChunkedRequestKeepAlive);
CppUnit_addTest(pSuite, HTTPSServerTest, test100Continue); CppUnit_addTest(pSuite, HTTPSServerTest, test100Continue);
CppUnit_addTest(pSuite, HTTPSServerTest, testRedirect); CppUnit_addTest(pSuite, HTTPSServerTest, testRedirect);
CppUnit_addTest(pSuite, HTTPSServerTest, testAuth); CppUnit_addTest(pSuite, HTTPSServerTest, testAuth);
CppUnit_addTest(pSuite, HTTPSServerTest, testNotImpl); CppUnit_addTest(pSuite, HTTPSServerTest, testNotImpl);
return pSuite; return pSuite;
} }

View File

@@ -1,153 +1,159 @@
// //
// HTTPSStreamFactoryTest.cpp // HTTPSStreamFactoryTest.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp#8 $ // $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp#8 $
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "HTTPSStreamFactoryTest.h" #include "HTTPSStreamFactoryTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Net/HTTPSStreamFactory.h" #include "Poco/Net/HTTPSStreamFactory.h"
#include "Poco/Net/NetException.h" #include "Poco/Net/NetException.h"
#include "Poco/URI.h" #include "Poco/Util/Application.h"
#include "Poco/Exception.h" #include "Poco/Util/AbstractConfiguration.h"
#include "Poco/StreamCopier.h" #include "Poco/URI.h"
#include "HTTPSTestServer.h" #include "Poco/Exception.h"
#include <sstream> #include "Poco/StreamCopier.h"
#include <memory> #include "HTTPSTestServer.h"
#include <sstream>
#include <memory>
using Poco::Net::HTTPSStreamFactory;
using Poco::Net::NetException;
using Poco::Net::HTTPException; using Poco::Net::HTTPSStreamFactory;
using Poco::URI; using Poco::Net::NetException;
using Poco::StreamCopier; using Poco::Net::HTTPException;
using Poco::Util::Application;
using Poco::URI;
HTTPSStreamFactoryTest::HTTPSStreamFactoryTest(const std::string& name): CppUnit::TestCase(name) using Poco::StreamCopier;
{
}
HTTPSStreamFactoryTest::HTTPSStreamFactoryTest(const std::string& name): CppUnit::TestCase(name)
{
HTTPSStreamFactoryTest::~HTTPSStreamFactoryTest() }
{
}
HTTPSStreamFactoryTest::~HTTPSStreamFactoryTest()
{
void HTTPSStreamFactoryTest::testNoRedirect() }
{
HTTPSTestServer server;
HTTPSStreamFactory factory; void HTTPSStreamFactoryTest::testNoRedirect()
URI uri("https://localhost/large"); {
uri.setPort(server.port()); HTTPSTestServer server;
std::auto_ptr<std::istream> pStr(factory.open(uri)); HTTPSStreamFactory factory;
std::ostringstream ostr; URI uri("https://localhost/large");
StreamCopier::copyStream(*pStr.get(), ostr); uri.setPort(server.port());
assert (ostr.str() == HTTPSTestServer::LARGE_BODY); std::auto_ptr<std::istream> pStr(factory.open(uri));
} std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::LARGE_BODY);
void HTTPSStreamFactoryTest::testEmptyPath() }
{
HTTPSTestServer server;
HTTPSStreamFactory factory; void HTTPSStreamFactoryTest::testEmptyPath()
URI uri("https://localhost"); {
uri.setPort(server.port()); HTTPSTestServer server;
std::auto_ptr<std::istream> pStr(factory.open(uri)); HTTPSStreamFactory factory;
std::ostringstream ostr; URI uri("https://localhost");
StreamCopier::copyStream(*pStr.get(), ostr); uri.setPort(server.port());
assert (ostr.str() == HTTPSTestServer::SMALL_BODY); std::auto_ptr<std::istream> pStr(factory.open(uri));
} std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::SMALL_BODY);
void HTTPSStreamFactoryTest::testRedirect() }
{
HTTPSTestServer server;
HTTPSStreamFactory factory; void HTTPSStreamFactoryTest::testRedirect()
URI uri("https://localhost/redirect"); {
uri.setPort(server.port()); HTTPSTestServer server;
std::auto_ptr<std::istream> pStr(factory.open(uri)); HTTPSStreamFactory factory;
std::ostringstream ostr; URI uri("https://localhost/redirect");
StreamCopier::copyStream(*pStr.get(), ostr); uri.setPort(server.port());
assert (ostr.str() == HTTPSTestServer::LARGE_BODY); std::auto_ptr<std::istream> pStr(factory.open(uri));
} std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::LARGE_BODY);
void HTTPSStreamFactoryTest::testProxy() }
{
HTTPSTestServer server;
HTTPSStreamFactory factory("proxy.aon.at", 8080); void HTTPSStreamFactoryTest::testProxy()
URI uri("https://sourceforge.net/"); {
std::auto_ptr<std::istream> pStr(factory.open(uri)); HTTPSTestServer server;
std::ostringstream ostr; HTTPSStreamFactory factory(
StreamCopier::copyStream(*pStr.get(), ostr); Application::instance().config().getString("testsuite.proxy.host"),
assert (ostr.str().length() > 0); Application::instance().config().getInt("testsuite.proxy.port")
} );
URI uri("https://secure.appinf.com/public/poco/NetSSL.txt");
std::auto_ptr<std::istream> pStr(factory.open(uri));
void HTTPSStreamFactoryTest::testError() std::ostringstream ostr;
{ StreamCopier::copyStream(*pStr.get(), ostr);
HTTPSTestServer server; assert (ostr.str().length() > 0);
HTTPSStreamFactory factory; }
URI uri("https://localhost/notfound");
uri.setPort(server.port());
try void HTTPSStreamFactoryTest::testError()
{ {
std::istream* pStr = factory.open(uri); HTTPSTestServer server;
fail("not found - must throw"); HTTPSStreamFactory factory;
} URI uri("https://localhost/notfound");
catch (HTTPException& exc) uri.setPort(server.port());
{ try
std::string m = exc.displayText(); {
} std::istream* pStr = factory.open(uri);
} fail("not found - must throw");
}
catch (HTTPException& exc)
void HTTPSStreamFactoryTest::setUp() {
{ std::string m = exc.displayText();
} }
}
void HTTPSStreamFactoryTest::tearDown()
{ void HTTPSStreamFactoryTest::setUp()
} {
}
CppUnit::Test* HTTPSStreamFactoryTest::suite()
{ void HTTPSStreamFactoryTest::tearDown()
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("HTTPSStreamFactoryTest"); {
}
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testNoRedirect);
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testEmptyPath);
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testRedirect); CppUnit::Test* HTTPSStreamFactoryTest::suite()
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testProxy); {
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testError); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("HTTPSStreamFactoryTest");
return pSuite; CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testNoRedirect);
} CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testEmptyPath);
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testRedirect);
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testProxy);
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testError);
return pSuite;
}

View File

@@ -1,241 +1,252 @@
// //
// HTTPSTestServer.cpp // HTTPSTestServer.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSTestServer.cpp#9 $ // $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSTestServer.cpp#9 $
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "HTTPSTestServer.h" #include "HTTPSTestServer.h"
#include "Poco/Net/SecureStreamSocket.h" #include "Poco/Net/SecureStreamSocket.h"
#include "Poco/Net/SocketAddress.h" #include "Poco/Net/SocketAddress.h"
#include "Poco/Timespan.h" #include "Poco/Timespan.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
#include <iostream> #include <iostream>
using Poco::Net::Socket; using Poco::Net::Socket;
using Poco::Net::StreamSocket; using Poco::Net::StreamSocket;
using Poco::Net::SecureStreamSocket; using Poco::Net::SecureStreamSocket;
using Poco::Net::SecureServerSocket; using Poco::Net::SecureServerSocket;
using Poco::Net::SocketAddress; using Poco::Net::SocketAddress;
using Poco::NumberFormatter; using Poco::NumberFormatter;
const std::string HTTPSTestServer::SMALL_BODY("This is some random text data returned by the server"); const std::string HTTPSTestServer::SMALL_BODY("This is some random text data returned by the server");
const std::string HTTPSTestServer::LARGE_BODY(4000, 'x'); const std::string HTTPSTestServer::LARGE_BODY(4000, 'x');
HTTPSTestServer::HTTPSTestServer(): HTTPSTestServer::HTTPSTestServer():
_socket(SocketAddress()), _socket(SocketAddress()),
_thread("HTTPSTestServer"), _thread("HTTPSTestServer"),
_stop(false) _stop(false)
{ {
_thread.start(*this); _thread.start(*this);
_ready.wait(); _ready.wait();
_lastRequest.reserve(4000); _lastRequest.reserve(4000);
} }
HTTPSTestServer::~HTTPSTestServer() HTTPSTestServer::HTTPSTestServer(Poco::Net::Context::Ptr pContext):
{ _socket(SocketAddress(), 64, pContext),
_stop = true; _thread("HTTPSTestServer"),
_thread.join(); _stop(false)
} {
_thread.start(*this);
_ready.wait();
Poco::UInt16 HTTPSTestServer::port() const _lastRequest.reserve(4000);
{ }
return _socket.address().port();
}
HTTPSTestServer::~HTTPSTestServer()
{
const std::string& HTTPSTestServer::lastRequest() const _stop = true;
{ _thread.join();
return _lastRequest; }
}
Poco::UInt16 HTTPSTestServer::port() const
void HTTPSTestServer::run() {
{ return _socket.address().port();
_ready.set(); }
Poco::Timespan span(250000);
while (!_stop)
{ const std::string& HTTPSTestServer::lastRequest() const
if (_socket.poll(span, Socket::SELECT_READ)) {
{ return _lastRequest;
StreamSocket ss = _socket.acceptConnection(); }
try
{
_lastRequest.clear(); void HTTPSTestServer::run()
char buffer[256]; {
int n = ss.receiveBytes(buffer, sizeof(buffer)); _ready.set();
while (n > 0 && !_stop) Poco::Timespan span(250000);
{ while (!_stop)
_lastRequest.append(buffer, n); {
if (!requestComplete()) if (_socket.poll(span, Socket::SELECT_READ))
n = ss.receiveBytes(buffer, sizeof(buffer)); {
else StreamSocket ss = _socket.acceptConnection();
n = 0; try
} {
std::string response = handleRequest(); _lastRequest.clear();
ss.sendBytes(response.data(), (int) response.size()); char buffer[256];
Poco::Thread::sleep(1000); int n = ss.receiveBytes(buffer, sizeof(buffer));
} while (n > 0 && !_stop)
catch (Poco::Exception& exc) {
{ _lastRequest.append(buffer, n);
std::cerr << "HTTPSTestServer: " << exc.displayText() << std::endl; if (!requestComplete())
} n = ss.receiveBytes(buffer, sizeof(buffer));
} else
} n = 0;
} }
std::string response = handleRequest();
ss.sendBytes(response.data(), (int) response.size());
bool HTTPSTestServer::requestComplete() const Poco::Thread::sleep(1000);
{ }
return ((_lastRequest.substr(0, 3) == "GET" || _lastRequest.substr(0, 4) == "HEAD") && catch (Poco::Exception& exc)
(_lastRequest.find("\r\n\r\n") != std::string::npos)) || {
(_lastRequest.find("\r\n0\r\n") != std::string::npos); std::cerr << "HTTPSTestServer: " << exc.displayText() << std::endl;
} }
}
}
std::string HTTPSTestServer::handleRequest() const }
{
std::string response;
response.reserve(16000); bool HTTPSTestServer::requestComplete() const
if (_lastRequest.substr(0, 10) == "GET /small" || {
_lastRequest.substr(0, 11) == "HEAD /small") return ((_lastRequest.substr(0, 3) == "GET" || _lastRequest.substr(0, 4) == "HEAD") &&
{ (_lastRequest.find("\r\n\r\n") != std::string::npos)) ||
std::string body(SMALL_BODY); (_lastRequest.find("\r\n0\r\n") != std::string::npos);
response.append("HTTP/1.0 200 OK\r\n"); }
response.append("Content-Type: text/plain\r\n");
response.append("Content-Length: ");
response.append(NumberFormatter::format((int) body.size())); std::string HTTPSTestServer::handleRequest() const
response.append("\r\n"); {
response.append("Connection: Close\r\n"); std::string response;
response.append("\r\n"); response.reserve(16000);
if (_lastRequest.substr(0, 3) == "GET") if (_lastRequest.substr(0, 10) == "GET /small" ||
response.append(body); _lastRequest.substr(0, 11) == "HEAD /small")
} {
else if (_lastRequest.substr(0, 10) == "GET /large" || std::string body(SMALL_BODY);
_lastRequest.substr(0, 11) == "HEAD /large" || response.append("HTTP/1.0 200 OK\r\n");
_lastRequest.substr(0, 36) == "GET http://www.somehost.com:80/large") response.append("Content-Type: text/plain\r\n");
{ response.append("Content-Length: ");
std::string body(LARGE_BODY); response.append(NumberFormatter::format((int) body.size()));
response.append("HTTP/1.0 200 OK\r\n"); response.append("\r\n");
response.append("Content-Type: text/plain\r\n"); response.append("Connection: Close\r\n");
response.append("Content-Length: "); response.append("\r\n");
response.append(NumberFormatter::format((int) body.size())); if (_lastRequest.substr(0, 3) == "GET")
response.append("\r\n"); response.append(body);
response.append("Connection: Close\r\n"); }
response.append("\r\n"); else if (_lastRequest.substr(0, 10) == "GET /large" ||
if (_lastRequest.substr(0, 3) == "GET") _lastRequest.substr(0, 11) == "HEAD /large" ||
response.append(body); _lastRequest.substr(0, 36) == "GET http://www.somehost.com:80/large")
} {
else if (_lastRequest.substr(0, 4) == "POST") std::string body(LARGE_BODY);
{ response.append("HTTP/1.0 200 OK\r\n");
std::string::size_type pos = _lastRequest.find("\r\n\r\n"); response.append("Content-Type: text/plain\r\n");
pos += 4; response.append("Content-Length: ");
std::string body = _lastRequest.substr(pos); response.append(NumberFormatter::format((int) body.size()));
response.append("HTTP/1.0 200 OK\r\n"); response.append("\r\n");
response.append("Content-Type: text/plain\r\n"); response.append("Connection: Close\r\n");
if (_lastRequest.find("Content-Length") != std::string::npos) response.append("\r\n");
{ if (_lastRequest.substr(0, 3) == "GET")
response.append("Content-Length: "); response.append(body);
response.append(NumberFormatter::format((int) body.size())); }
response.append("\r\n"); else if (_lastRequest.substr(0, 4) == "POST")
} {
else if (_lastRequest.find("chunked") != std::string::npos) std::string::size_type pos = _lastRequest.find("\r\n\r\n");
{ pos += 4;
response.append("Transfer-Encoding: chunked\r\n"); std::string body = _lastRequest.substr(pos);
} response.append("HTTP/1.0 200 OK\r\n");
if (_lastRequest.substr(0,15) == "POST /keepAlive") response.append("Content-Type: text/plain\r\n");
response.append("Connection: keep-alive\r\n"); if (_lastRequest.find("Content-Length") != std::string::npos)
else {
response.append("Connection: Close\r\n"); response.append("Content-Length: ");
response.append("\r\n"); response.append(NumberFormatter::format((int) body.size()));
response.append(body); response.append("\r\n");
} }
else if (_lastRequest.substr(0, 15) == "HEAD /keepAlive") else if (_lastRequest.find("chunked") != std::string::npos)
{ {
std::string body(SMALL_BODY); response.append("Transfer-Encoding: chunked\r\n");
response.append("HTTP/1.1 200 OK\r\n"); }
response.append("Connection: keep-alive\r\n"); if (_lastRequest.substr(0,15) == "POST /keepAlive")
response.append("Content-Type: text/plain\r\n"); response.append("Connection: keep-alive\r\n");
response.append("Content-Length: "); else
response.append(NumberFormatter::format((int) body.size())); response.append("Connection: Close\r\n");
response.append("\r\n\r\n"); response.append("\r\n");
response.append("HTTP/1.1 200 OK\r\n"); response.append(body);
response.append("Connection: Keep-Alive\r\n"); }
response.append("Content-Type: text/plain\r\n"); else if (_lastRequest.substr(0, 15) == "HEAD /keepAlive")
response.append("Content-Length: "); {
response.append(NumberFormatter::format((int) body.size())); std::string body(SMALL_BODY);
response.append("\r\n\r\n"); response.append("HTTP/1.1 200 OK\r\n");
response.append(body); response.append("Connection: keep-alive\r\n");
body = LARGE_BODY; response.append("Content-Type: text/plain\r\n");
response.append("HTTP/1.1 200 OK\r\n"); response.append("Content-Length: ");
response.append("Connection: keep-alive\r\n"); response.append(NumberFormatter::format((int) body.size()));
response.append("Content-Type: text/plain\r\n"); response.append("\r\n\r\n");
response.append("Transfer-Encoding: chunked\r\n\r\n"); response.append("HTTP/1.1 200 OK\r\n");
response.append(NumberFormatter::formatHex((unsigned) body.length())); response.append("Connection: Keep-Alive\r\n");
response.append("\r\n"); response.append("Content-Type: text/plain\r\n");
response.append(body); response.append("Content-Length: ");
response.append("\r\n0\r\n\r\n"); response.append(NumberFormatter::format((int) body.size()));
response.append("HTTP/1.1 200 OK\r\n"); response.append("\r\n\r\n");
response.append("Connection: close\r\n"); response.append(body);
response.append("Content-Type: text/plain\r\n"); body = LARGE_BODY;
response.append("Content-Length: "); response.append("HTTP/1.1 200 OK\r\n");
response.append(NumberFormatter::format((int) body.size())); response.append("Connection: keep-alive\r\n");
response.append("\r\n\r\n"); response.append("Content-Type: text/plain\r\n");
} response.append("Transfer-Encoding: chunked\r\n\r\n");
else if (_lastRequest.substr(0, 13) == "GET /redirect") response.append(NumberFormatter::formatHex((unsigned) body.length()));
{ response.append("\r\n");
response.append("HTTP/1.0 302 Found\r\n"); response.append(body);
response.append("Location: /large\r\n"); response.append("\r\n0\r\n\r\n");
response.append("\r\n"); response.append("HTTP/1.1 200 OK\r\n");
} response.append("Connection: close\r\n");
else if (_lastRequest.substr(0, 13) == "GET /notfound") response.append("Content-Type: text/plain\r\n");
{ response.append("Content-Length: ");
response.append("HTTP/1.0 404 Not Found\r\n"); response.append(NumberFormatter::format((int) body.size()));
response.append("\r\n"); response.append("\r\n\r\n");
} }
else if (_lastRequest.substr(0, 5) == "GET /" || else if (_lastRequest.substr(0, 13) == "GET /redirect")
_lastRequest.substr(0, 6) == "HEAD /") {
{ response.append("HTTP/1.0 302 Found\r\n");
std::string body(SMALL_BODY); response.append("Location: /large\r\n");
response.append("HTTP/1.0 200 OK\r\n"); response.append("\r\n");
response.append("Content-Type: text/plain\r\n"); }
response.append("Content-Length: "); else if (_lastRequest.substr(0, 13) == "GET /notfound")
response.append(NumberFormatter::format((int) body.size())); {
response.append("\r\n"); response.append("HTTP/1.0 404 Not Found\r\n");
response.append("Connection: Close\r\n"); response.append("\r\n");
response.append("\r\n"); }
if (_lastRequest.substr(0, 3) == "GET") else if (_lastRequest.substr(0, 5) == "GET /" ||
response.append(body); _lastRequest.substr(0, 6) == "HEAD /")
} {
return response; std::string body(SMALL_BODY);
} response.append("HTTP/1.0 200 OK\r\n");
response.append("Content-Type: text/plain\r\n");
response.append("Content-Length: ");
response.append(NumberFormatter::format((int) body.size()));
response.append("\r\n");
response.append("Connection: Close\r\n");
response.append("\r\n");
if (_lastRequest.substr(0, 3) == "GET")
response.append(body);
}
return response;
}

View File

@@ -1,81 +1,84 @@
// //
// HTTPSTestServer.h // HTTPSTestServer.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSTestServer.h#7 $ // $Id: //poco/1.4/NetSSL_OpenSSL/testsuite/src/HTTPSTestServer.h#1 $
// //
// Definition of the HTTPSTestServer class. // Definition of the HTTPSTestServer class.
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef HTTPSTestServer_INCLUDED #ifndef HTTPSTestServer_INCLUDED
#define HTTPSTestServer_INCLUDED #define HTTPSTestServer_INCLUDED
#include "Poco/Net/Net.h" #include "Poco/Net/Net.h"
#include "Poco/Net/SecureServerSocket.h" #include "Poco/Net/SecureServerSocket.h"
#include "Poco/Thread.h" #include "Poco/Thread.h"
#include "Poco/Event.h" #include "Poco/Event.h"
class HTTPSTestServer: public Poco::Runnable class HTTPSTestServer: public Poco::Runnable
/// A simple sequential echo server. /// A simple sequential echo server.
{ {
public: public:
HTTPSTestServer(); HTTPSTestServer();
/// Creates the HTTPSTestServer. /// Creates the HTTPSTestServer.
~HTTPSTestServer(); explicit HTTPSTestServer(Poco::Net::Context::Ptr pContext);
/// Destroys the HTTPSTestServer. /// Creates the HTTPSTestServer using the given Context.
Poco::UInt16 port() const; ~HTTPSTestServer();
/// Returns the port the echo server is /// Destroys the HTTPSTestServer.
/// listening on.
Poco::UInt16 port() const;
void run(); /// Returns the port the echo server is
/// Does the work. /// listening on.
const std::string& lastRequest() const; void run();
/// Returns the last request. /// Does the work.
static const std::string SMALL_BODY; const std::string& lastRequest() const;
static const std::string LARGE_BODY; /// Returns the last request.
protected: static const std::string SMALL_BODY;
bool requestComplete() const; static const std::string LARGE_BODY;
std::string handleRequest() const;
protected:
private: bool requestComplete() const;
Poco::Net::SecureServerSocket _socket; std::string handleRequest() const;
Poco::Thread _thread;
Poco::Event _ready; private:
bool _stop; Poco::Net::SecureServerSocket _socket;
std::string _lastRequest; Poco::Thread _thread;
}; Poco::Event _ready;
bool _stop;
std::string _lastRequest;
#endif // HTTPSTestServer_INCLUDED };
#endif // HTTPSTestServer_INCLUDED

View File

@@ -1,277 +1,427 @@
// //
// TCPServerTest.cpp // TCPServerTest.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/TCPServerTest.cpp#7 $ // $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/TCPServerTest.cpp#7 $
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "TCPServerTest.h" #include "TCPServerTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Net/TCPServer.h" #include "Poco/Net/TCPServer.h"
#include "Poco/Net/TCPServerConnection.h" #include "Poco/Net/TCPServerConnection.h"
#include "Poco/Net/TCPServerConnectionFactory.h" #include "Poco/Net/TCPServerConnectionFactory.h"
#include "Poco/Net/TCPServerParams.h" #include "Poco/Net/TCPServerParams.h"
#include "Poco/Net/SecureStreamSocket.h" #include "Poco/Net/SecureStreamSocket.h"
#include "Poco/Net/SecureServerSocket.h" #include "Poco/Net/SecureServerSocket.h"
#include "Poco/Thread.h" #include "Poco/Net/Context.h"
#include <iostream> #include "Poco/Net/Session.h"
#include "Poco/Net/SSLManager.h"
#include "Poco/Util/Application.h"
using Poco::Net::TCPServer; #include "Poco/Util/AbstractConfiguration.h"
using Poco::Net::TCPServerConnection; #include "Poco/Thread.h"
using Poco::Net::TCPServerConnectionFactory; #include <iostream>
using Poco::Net::TCPServerConnectionFactoryImpl;
using Poco::Net::TCPServerParams;
using Poco::Net::StreamSocket; using Poco::Net::TCPServer;
using Poco::Net::SecureStreamSocket; using Poco::Net::TCPServerConnection;
using Poco::Net::SecureServerSocket; using Poco::Net::TCPServerConnectionFactory;
using Poco::Net::SocketAddress; using Poco::Net::TCPServerConnectionFactoryImpl;
using Poco::Thread; using Poco::Net::TCPServerParams;
using Poco::Net::StreamSocket;
using Poco::Net::SecureStreamSocket;
namespace using Poco::Net::SecureServerSocket;
{ using Poco::Net::SocketAddress;
class EchoConnection: public TCPServerConnection using Poco::Net::Context;
{ using Poco::Net::Session;
public: using Poco::Net::SSLManager;
EchoConnection(const StreamSocket& s): TCPServerConnection(s) using Poco::Thread;
{ using Poco::Util::Application;
}
void run() namespace
{ {
StreamSocket& ss = socket(); class EchoConnection: public TCPServerConnection
try {
{ public:
char buffer[256]; EchoConnection(const StreamSocket& s): TCPServerConnection(s)
int n = ss.receiveBytes(buffer, sizeof(buffer)); {
while (n > 0) }
{
ss.sendBytes(buffer, n); void run()
n = ss.receiveBytes(buffer, sizeof(buffer)); {
} StreamSocket& ss = socket();
} try
catch (Poco::Exception& exc) {
{ char buffer[256];
std::cerr << "EchoConnection: " << exc.displayText() << std::endl; int n = ss.receiveBytes(buffer, sizeof(buffer));
} while (n > 0)
} {
}; ss.sendBytes(buffer, n);
} n = ss.receiveBytes(buffer, sizeof(buffer));
}
}
TCPServerTest::TCPServerTest(const std::string& name): CppUnit::TestCase(name) catch (Poco::Exception& exc)
{ {
} std::cerr << "EchoConnection: " << exc.displayText() << std::endl;
}
}
TCPServerTest::~TCPServerTest() };
{ }
}
TCPServerTest::TCPServerTest(const std::string& name): CppUnit::TestCase(name)
void TCPServerTest::testOneConnection() {
{ }
SecureServerSocket svs(0);
TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs);
srv.start(); TCPServerTest::~TCPServerTest()
assert (srv.currentConnections() == 0); {
assert (srv.currentThreads() == 0); }
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 0);
void TCPServerTest::testOneConnection()
SocketAddress sa("localhost", svs.address().port()); {
SecureStreamSocket ss1(sa); SecureServerSocket svs(0);
std::string data("hello, world"); TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs);
ss1.sendBytes(data.data(), (int) data.size()); srv.start();
char buffer[256]; assert (srv.currentConnections() == 0);
int n = ss1.receiveBytes(buffer, sizeof(buffer)); assert (srv.currentThreads() == 0);
assert (n > 0); assert (srv.queuedConnections() == 0);
assert (std::string(buffer, n) == data); assert (srv.totalConnections() == 0);
assert (srv.currentConnections() == 1);
assert (srv.currentThreads() == 1); SocketAddress sa("localhost", svs.address().port());
assert (srv.queuedConnections() == 0); SecureStreamSocket ss1(sa);
assert (srv.totalConnections() == 1); std::string data("hello, world");
ss1.close(); ss1.sendBytes(data.data(), (int) data.size());
Thread::sleep(300); char buffer[256];
assert (srv.currentConnections() == 0); int n = ss1.receiveBytes(buffer, sizeof(buffer));
} assert (n > 0);
assert (std::string(buffer, n) == data);
assert (srv.currentConnections() == 1);
void TCPServerTest::testTwoConnections() assert (srv.currentThreads() == 1);
{ assert (srv.queuedConnections() == 0);
SecureServerSocket svs(0); assert (srv.totalConnections() == 1);
TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs); ss1.close();
srv.start(); Thread::sleep(300);
assert (srv.currentConnections() == 0); assert (srv.currentConnections() == 0);
assert (srv.currentThreads() == 0); }
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 0);
void TCPServerTest::testTwoConnections()
SocketAddress sa("localhost", svs.address().port()); {
SecureStreamSocket ss1(sa); SecureServerSocket svs(0);
SecureStreamSocket ss2(sa); TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs);
std::string data("hello, world"); srv.start();
ss1.sendBytes(data.data(), (int) data.size()); assert (srv.currentConnections() == 0);
ss2.sendBytes(data.data(), (int) data.size()); assert (srv.currentThreads() == 0);
assert (srv.queuedConnections() == 0);
char buffer[256]; assert (srv.totalConnections() == 0);
int n = ss1.receiveBytes(buffer, sizeof(buffer));
assert (n > 0); SocketAddress sa("localhost", svs.address().port());
assert (std::string(buffer, n) == data); SecureStreamSocket ss1(sa);
SecureStreamSocket ss2(sa);
n = ss2.receiveBytes(buffer, sizeof(buffer)); std::string data("hello, world");
assert (n > 0); ss1.sendBytes(data.data(), (int) data.size());
assert (std::string(buffer, n) == data); ss2.sendBytes(data.data(), (int) data.size());
assert (srv.currentConnections() == 2); char buffer[256];
assert (srv.currentThreads() == 2); int n = ss1.receiveBytes(buffer, sizeof(buffer));
assert (srv.queuedConnections() == 0); assert (n > 0);
assert (srv.totalConnections() == 2); assert (std::string(buffer, n) == data);
ss1.close();
Thread::sleep(300); n = ss2.receiveBytes(buffer, sizeof(buffer));
assert (srv.currentConnections() == 1); assert (n > 0);
assert (srv.currentThreads() == 1); assert (std::string(buffer, n) == data);
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 2); assert (srv.currentConnections() == 2);
ss2.close(); assert (srv.currentThreads() == 2);
assert (srv.queuedConnections() == 0);
Thread::sleep(300); assert (srv.totalConnections() == 2);
assert (srv.currentConnections() == 0); ss1.close();
} Thread::sleep(300);
assert (srv.currentConnections() == 1);
assert (srv.currentThreads() == 1);
void TCPServerTest::testMultiConnections() assert (srv.queuedConnections() == 0);
{ assert (srv.totalConnections() == 2);
SecureServerSocket svs(0); ss2.close();
TCPServerParams* pParams = new TCPServerParams;
pParams->setMaxThreads(4); Thread::sleep(300);
pParams->setMaxQueued(4); assert (srv.currentConnections() == 0);
pParams->setThreadIdleTime(100); }
TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs, pParams);
srv.start();
assert (srv.currentConnections() == 0); void TCPServerTest::testMultiConnections()
assert (srv.currentThreads() == 0); {
assert (srv.queuedConnections() == 0); SecureServerSocket svs(0);
assert (srv.totalConnections() == 0); TCPServerParams* pParams = new TCPServerParams;
pParams->setMaxThreads(4);
SocketAddress sa("localhost", svs.address().port()); pParams->setMaxQueued(4);
SecureStreamSocket ss1(sa); pParams->setThreadIdleTime(100);
SecureStreamSocket ss2(sa); TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs, pParams);
SecureStreamSocket ss3(sa); srv.start();
SecureStreamSocket ss4(sa); assert (srv.currentConnections() == 0);
std::string data("hello, world"); assert (srv.currentThreads() == 0);
ss1.sendBytes(data.data(), (int) data.size()); assert (srv.queuedConnections() == 0);
ss2.sendBytes(data.data(), (int) data.size()); assert (srv.totalConnections() == 0);
ss3.sendBytes(data.data(), (int) data.size());
ss4.sendBytes(data.data(), (int) data.size()); SocketAddress sa("localhost", svs.address().port());
SecureStreamSocket ss1(sa);
char buffer[256]; SecureStreamSocket ss2(sa);
int n = ss1.receiveBytes(buffer, sizeof(buffer)); SecureStreamSocket ss3(sa);
assert (n > 0); SecureStreamSocket ss4(sa);
assert (std::string(buffer, n) == data); std::string data("hello, world");
ss1.sendBytes(data.data(), (int) data.size());
n = ss2.receiveBytes(buffer, sizeof(buffer)); ss2.sendBytes(data.data(), (int) data.size());
assert (n > 0); ss3.sendBytes(data.data(), (int) data.size());
assert (std::string(buffer, n) == data); ss4.sendBytes(data.data(), (int) data.size());
n = ss3.receiveBytes(buffer, sizeof(buffer)); char buffer[256];
assert (n > 0); int n = ss1.receiveBytes(buffer, sizeof(buffer));
assert (std::string(buffer, n) == data); assert (n > 0);
assert (std::string(buffer, n) == data);
n = ss4.receiveBytes(buffer, sizeof(buffer));
assert (n > 0); n = ss2.receiveBytes(buffer, sizeof(buffer));
assert (std::string(buffer, n) == data); assert (n > 0);
assert (std::string(buffer, n) == data);
assert (srv.currentConnections() == 4);
assert (srv.currentThreads() == 4); n = ss3.receiveBytes(buffer, sizeof(buffer));
assert (srv.queuedConnections() == 0); assert (n > 0);
assert (srv.totalConnections() == 4); assert (std::string(buffer, n) == data);
SecureStreamSocket ss5(sa); n = ss4.receiveBytes(buffer, sizeof(buffer));
Thread::sleep(200); assert (n > 0);
assert (srv.queuedConnections() == 1); assert (std::string(buffer, n) == data);
SecureStreamSocket ss6(sa);
Thread::sleep(200); assert (srv.currentConnections() == 4);
assert (srv.queuedConnections() == 2); assert (srv.currentThreads() == 4);
assert (srv.queuedConnections() == 0);
ss1.close(); assert (srv.totalConnections() == 4);
Thread::sleep(300);
assert (srv.currentConnections() == 4); SecureStreamSocket ss5;
assert (srv.currentThreads() == 4); ss5.setLazyHandshake();
assert (srv.queuedConnections() == 1); ss5.connect(sa);
assert (srv.totalConnections() == 5); Thread::sleep(200);
assert (srv.queuedConnections() == 1);
ss2.close(); SecureStreamSocket ss6;
Thread::sleep(300); ss6.setLazyHandshake();
assert (srv.currentConnections() == 4); ss6.connect(sa);
assert (srv.currentThreads() == 4); Thread::sleep(200);
assert (srv.queuedConnections() == 0); assert (srv.queuedConnections() == 2);
assert (srv.totalConnections() == 6);
ss1.close();
ss3.close(); Thread::sleep(300);
Thread::sleep(300); assert (srv.currentConnections() == 4);
assert (srv.currentConnections() == 3); assert (srv.currentThreads() == 4);
assert (srv.currentThreads() == 3); assert (srv.queuedConnections() == 1);
assert (srv.queuedConnections() == 0); assert (srv.totalConnections() == 5);
assert (srv.totalConnections() == 6);
ss2.close();
ss4.close(); Thread::sleep(300);
Thread::sleep(300); assert (srv.currentConnections() == 4);
assert (srv.currentConnections() == 2); assert (srv.currentThreads() == 4);
assert (srv.currentThreads() == 2); assert (srv.queuedConnections() == 0);
assert (srv.queuedConnections() == 0); assert (srv.totalConnections() == 6);
assert (srv.totalConnections() == 6);
ss3.close();
ss5.close(); Thread::sleep(300);
ss6.close(); assert (srv.currentConnections() == 3);
Thread::sleep(300); assert (srv.currentThreads() == 3);
assert (srv.currentConnections() == 0);} assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 6);
void TCPServerTest::setUp() ss4.close();
{ Thread::sleep(300);
} assert (srv.currentConnections() == 2);
assert (srv.currentThreads() == 2);
assert (srv.queuedConnections() == 0);
void TCPServerTest::tearDown() assert (srv.totalConnections() == 6);
{
} ss5.close();
ss6.close();
Thread::sleep(300);
CppUnit::Test* TCPServerTest::suite() assert (srv.currentConnections() == 0);
{ }
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TCPServerTest");
CppUnit_addTest(pSuite, TCPServerTest, testOneConnection); void TCPServerTest::testReuseSocket()
CppUnit_addTest(pSuite, TCPServerTest, testTwoConnections); {
CppUnit_addTest(pSuite, TCPServerTest, testMultiConnections); SecureServerSocket svs(0);
TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs);
return pSuite; srv.start();
} assert (srv.currentConnections() == 0);
assert (srv.currentThreads() == 0);
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 0);
SocketAddress sa("localhost", svs.address().port());
SecureStreamSocket ss1(sa);
std::string data("hello, world");
ss1.sendBytes(data.data(), (int) data.size());
char buffer[256];
int n = ss1.receiveBytes(buffer, sizeof(buffer));
assert (n > 0);
assert (std::string(buffer, n) == data);
assert (srv.currentConnections() == 1);
assert (srv.currentThreads() == 1);
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 1);
ss1.close();
Thread::sleep(300);
assert (srv.currentConnections() == 0);
ss1.connect(sa);
ss1.sendBytes(data.data(), (int) data.size());
n = ss1.receiveBytes(buffer, sizeof(buffer));
assert (n > 0);
assert (std::string(buffer, n) == data);
assert (srv.currentConnections() == 1);
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 2);
ss1.close();
Thread::sleep(300);
assert (srv.currentConnections() == 0);
}
void TCPServerTest::testReuseSession()
{
// ensure OpenSSL machinery is fully setup
Context::Ptr pDefaultServerContext = SSLManager::instance().defaultServerContext();
Context::Ptr pDefaultClientContext = SSLManager::instance().defaultClientContext();
Context::Ptr pServerContext = new Context(
Context::SERVER_USE,
Application::instance().config().getString("openSSL.server.privateKeyFile"),
Application::instance().config().getString("openSSL.server.privateKeyFile"),
Application::instance().config().getString("openSSL.server.caConfig"),
Context::VERIFY_NONE,
9,
true,
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
pServerContext->enableSessionCache(true, "TestSuite");
pServerContext->setSessionTimeout(10);
pServerContext->setSessionCacheSize(1000);
pServerContext->disableStatelessSessionResumption();
SecureServerSocket svs(0, 64, pServerContext);
TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs);
srv.start();
assert (srv.currentConnections() == 0);
assert (srv.currentThreads() == 0);
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 0);
Context::Ptr pClientContext = new Context(
Context::SERVER_USE,
Application::instance().config().getString("openSSL.client.privateKeyFile"),
Application::instance().config().getString("openSSL.client.privateKeyFile"),
Application::instance().config().getString("openSSL.client.caConfig"),
Context::VERIFY_RELAXED,
9,
true,
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
pClientContext->enableSessionCache(true);
SocketAddress sa("localhost", svs.address().port());
SecureStreamSocket ss1(sa, pClientContext);
assert (!ss1.sessionWasReused());
std::string data("hello, world");
ss1.sendBytes(data.data(), (int) data.size());
char buffer[256];
int n = ss1.receiveBytes(buffer, sizeof(buffer));
assert (n > 0);
assert (std::string(buffer, n) == data);
assert (srv.currentConnections() == 1);
assert (srv.currentThreads() == 1);
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 1);
Session::Ptr pSession = ss1.currentSession();
ss1.close();
Thread::sleep(300);
assert (srv.currentConnections() == 0);
ss1.useSession(pSession);
ss1.connect(sa);
assert (ss1.sessionWasReused());
assert (ss1.currentSession() == pSession);
ss1.sendBytes(data.data(), (int) data.size());
n = ss1.receiveBytes(buffer, sizeof(buffer));
assert (n > 0);
assert (std::string(buffer, n) == data);
assert (srv.currentConnections() == 1);
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 2);
ss1.close();
Thread::sleep(300);
assert (srv.currentConnections() == 0);
Thread::sleep(15000); // wait for session to expire
pServerContext->flushSessionCache();
ss1.useSession(pSession);
ss1.connect(sa);
assert (!ss1.sessionWasReused());
assert (ss1.currentSession() != pSession);
ss1.sendBytes(data.data(), (int) data.size());
n = ss1.receiveBytes(buffer, sizeof(buffer));
assert (n > 0);
assert (std::string(buffer, n) == data);
assert (srv.currentConnections() == 1);
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 3);
ss1.close();
Thread::sleep(300);
assert (srv.currentConnections() == 0);
}
void TCPServerTest::setUp()
{
}
void TCPServerTest::tearDown()
{
}
CppUnit::Test* TCPServerTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TCPServerTest");
CppUnit_addTest(pSuite, TCPServerTest, testOneConnection);
CppUnit_addTest(pSuite, TCPServerTest, testTwoConnections);
CppUnit_addTest(pSuite, TCPServerTest, testMultiConnections);
CppUnit_addTest(pSuite, TCPServerTest, testReuseSocket);
CppUnit_addTest(pSuite, TCPServerTest, testReuseSession);
return pSuite;
}

View File

@@ -1,62 +1,64 @@
// //
// TCPServerTest.h // TCPServerTest.h
// //
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/TCPServerTest.h#7 $ // $Id: //poco/1.4/NetSSL_OpenSSL/testsuite/src/TCPServerTest.h#1 $
// //
// Definition of the TCPServerTest class. // Definition of the TCPServerTest class.
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef TCPServerTest_INCLUDED #ifndef TCPServerTest_INCLUDED
#define TCPServerTest_INCLUDED #define TCPServerTest_INCLUDED
#include "Poco/Net/Net.h" #include "Poco/Net/Net.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
class TCPServerTest: public CppUnit::TestCase class TCPServerTest: public CppUnit::TestCase
{ {
public: public:
TCPServerTest(const std::string& name); TCPServerTest(const std::string& name);
~TCPServerTest(); ~TCPServerTest();
void testOneConnection(); void testOneConnection();
void testTwoConnections(); void testTwoConnections();
void testMultiConnections(); void testMultiConnections();
void testReuseSocket();
void setUp(); void testReuseSession();
void tearDown();
void setUp();
static CppUnit::Test* suite(); void tearDown();
private: static CppUnit::Test* suite();
};
private:
};
#endif // TCPServerTest_INCLUDED
#endif // TCPServerTest_INCLUDED

View File

@@ -0,0 +1,110 @@
//
// WinCEDriver.cpp
//
// $Id: //poco/1.4/NetSSL_OpenSSL/testsuite/src/WinCEDriver.cpp#1 $
//
// Console-based test driver for Windows CE.
//
// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "CppUnit/TestRunner.h"
#include "NetSSLTestSuite.h"
#include "Poco/Util/Application.h"
#include "Poco/Net/HTTPStreamFactory.h"
#include "Poco/Net/HTTPSStreamFactory.h"
#include <cstdlib>
class NetSSLApp: public Poco::Util::Application
{
public:
NetSSLApp()
{
Poco::Net::initializeSSL();
Poco::Net::HTTPStreamFactory::registerFactory();
Poco::Net::HTTPSStreamFactory::registerFactory();
}
~NetSSLApp()
{
Poco::Net::uninitializeSSL();
}
int main(const std::vector<std::string>& args)
{
CppUnit::TestRunner runner;
runner.addTest("NetSSLTestSuite", NetSSLTestSuite::suite());
return runner.run(_targs) ? 0 : 1;
}
void setup(const std::vector<std::string>& args)
{
char* argv[] =
{
const_cast<char*>(args[0].c_str())
};
init(1, argv);
for (std::size_t i = 0; i < args.size(); ++i)
_targs.push_back(args[i]);
}
protected:
void initialize(Poco::Util::Application& self)
{
loadConfiguration(); // load default configuration files, if present
Poco::Util::Application::initialize(self);
}
private:
std::vector<std::string> _targs;
};
int _tmain(int argc, wchar_t* argv[])
{
std::vector<std::string> args;
for (int i = 0; i < argc; ++i)
{
char buffer[1024];
std::wcstombs(buffer, argv[i], sizeof(buffer));
args.push_back(std::string(buffer));
}
NetSSLApp app;
try
{
app.setup(args);
return app.run();
}
catch (Poco::Exception& exc)
{
std::cout << exc.displayText() << std::endl;
return 1;
}
}

View File

@@ -1,86 +1,97 @@
// //
// WinDriver.cpp // WinDriver.cpp
// //
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/WinDriver.cpp#8 $ // $Id: //poco/1.4/NetSSL_OpenSSL/testsuite/src/WinDriver.cpp#1 $
// //
// Windows test driver for Poco OpenSSL. // Windows test driver for Poco OpenSSL.
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "WinTestRunner/WinTestRunner.h" #include "WinTestRunner/WinTestRunner.h"
#include "NetSSLTestSuite.h" #include "NetSSLTestSuite.h"
#include "Poco/Util/Application.h" #include "Poco/Util/Application.h"
#include "Poco/Net/HTTPStreamFactory.h" #include "Poco/Net/HTTPStreamFactory.h"
#include "Poco/Net/HTTPSStreamFactory.h" #include "Poco/Net/HTTPSStreamFactory.h"
class NetSSLApp: public Poco::Util::Application class NetSSLApp: public Poco::Util::Application
{ {
public: public:
NetSSLApp() NetSSLApp()
{ {
} Poco::Net::initializeSSL();
Poco::Net::HTTPStreamFactory::registerFactory();
~NetSSLApp() Poco::Net::HTTPSStreamFactory::registerFactory();
{ }
}
~NetSSLApp()
protected: {
void initialize(Application& self) Poco::Net::uninitializeSSL();
{ }
loadConfiguration(); // load default configuration files, if present
Application::initialize(self); int main(const std::vector<std::string>& args)
} {
}; CppUnit::WinTestRunner runner;
runner.addTest(NetSSLTestSuite::suite());
runner.run();
class TestDriver: public CppUnit::WinTestRunnerApp return 0;
{ }
void TestMain()
{ protected:
CppUnit::WinTestRunner runner; void initialize(Poco::Util::Application& self)
Poco::Net::HTTPStreamFactory::registerFactory(); {
Poco::Net::HTTPSStreamFactory::registerFactory(); loadConfiguration(); // load default configuration files, if present
NetSSLApp app; Poco::Util::Application::initialize(self);
std::string argv("OpenSSLTest"); }
const char* pArgv = argv.c_str();
try private:
{ std::vector<std::string> _targs;
app.init(1, (char**)&pArgv); };
}
catch (Poco::Exception& exc)
{ class TestDriver: public CppUnit::WinTestRunnerApp
app.logger().log(exc); {
} void TestMain()
runner.addTest(NetSSLTestSuite::suite()); {
runner.run(); NetSSLApp app;
} std::string argv("TestSuite");
}; const char* pArgv = argv.c_str();
try
{
static TestDriver theDriver; app.init(1, (char**)&pArgv);
app.run();
}
catch (Poco::Exception& exc)
{
app.logger().log(exc);
}
}
};
static TestDriver theDriver;

View File

@@ -1,42 +1,48 @@
<AppConfig> <AppConfig>
<openSSL> <openSSL>
<server> <server>
<privateKeyFile>${application.configDir}any.pem</privateKeyFile> <privateKeyFile>${application.configDir}any.pem</privateKeyFile>
<caConfig>${application.configDir}rootcert.pem</caConfig> <caConfig>${application.configDir}rootcert.pem</caConfig>
<verificationMode>none</verificationMode> <verificationMode>none</verificationMode>
<verificationDepth>9</verificationDepth> <verificationDepth>9</verificationDepth>
<loadDefaultCAFile>true</loadDefaultCAFile> <loadDefaultCAFile>true</loadDefaultCAFile>
<cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList> <cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList>
<privateKeyPassphraseHandler> <privateKeyPassphraseHandler>
<name>KeyFileHandler</name> <name>KeyFileHandler</name>
<options> <options>
<password>secret</password> <password>secret</password>
</options> </options>
</privateKeyPassphraseHandler> </privateKeyPassphraseHandler>
<invalidCertificateHandler> <invalidCertificateHandler>
<name>AcceptCertificateHandler</name> <name>AcceptCertificateHandler</name>
<options> <options>
</options> </options>
</invalidCertificateHandler> </invalidCertificateHandler>
</server> </server>
<client> <client>
<privateKeyFile>${application.configDir}any.pem</privateKeyFile> <privateKeyFile>${application.configDir}any.pem</privateKeyFile>
<caConfig>${application.configDir}rootcert.pem</caConfig> <caConfig>${application.configDir}rootcert.pem</caConfig>
<verificationMode>relaxed</verificationMode> <verificationMode>relaxed</verificationMode>
<verificationDepth>9</verificationDepth> <verificationDepth>9</verificationDepth>
<loadDefaultCAFile>true</loadDefaultCAFile> <loadDefaultCAFile>true</loadDefaultCAFile>
<cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList> <cypherList>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</cypherList>
<privateKeyPassphraseHandler> <privateKeyPassphraseHandler>
<name>KeyFileHandler</name> <name>KeyFileHandler</name>
<options> <options>
<password>secret</password> <password>secret</password>
</options> </options>
</privateKeyPassphraseHandler> </privateKeyPassphraseHandler>
<invalidCertificateHandler> <invalidCertificateHandler>
<name>AcceptCertificateHandler</name> <name>AcceptCertificateHandler</name>
<options> <options>
</options> </options>
</invalidCertificateHandler> </invalidCertificateHandler>
</client> </client>
</openSSL> </openSSL>
</AppConfig> <testsuite>
<proxy>
<host>proxy.aon.at</host>
<port>8080</port>
</proxy>
</testsuite>
</AppConfig>