Permalink
Browse files

Additional Certificate handling options and issue #54 fix

  • Loading branch information...
Redth committed Oct 24, 2012
1 parent bdfb871 commit 6494fe68b16d3f259f95c699e4131d074c1d3e0e
@@ -12,70 +12,71 @@
<AssemblyName>PushSharpClientSampleMonoTouch</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
- <DebugSymbols>true</DebugSymbols>
+ <DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
- <Optimize>false</Optimize>
+ <Optimize>False</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
- <MtouchDebug>true</MtouchDebug>
- <MtouchProfiling>true</MtouchProfiling>
+ <ConsolePause>False</ConsolePause>
+ <MtouchDebug>True</MtouchDebug>
+ <MtouchProfiling>True</MtouchProfiling>
<MtouchLink>None</MtouchLink>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
- <Optimize>true</Optimize>
+ <Optimize>True</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
+ <ConsolePause>False</ConsolePause>
<MtouchLink>None</MtouchLink>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
- <DebugSymbols>true</DebugSymbols>
+ <DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
- <Optimize>false</Optimize>
+ <Optimize>False</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
+ <ConsolePause>False</ConsolePause>
<CodesignKey>iPhone Developer</CodesignKey>
- <MtouchDebug>true</MtouchDebug>
- <MtouchProfiling>true</MtouchProfiling>
- <CodesignProvision>F8563C84-CCD1-44B7-9FCD-42ADCDFDFAB4</CodesignProvision>
+ <MtouchDebug>True</MtouchDebug>
+ <MtouchProfiling>True</MtouchProfiling>
+ <CodesignProvision>1B48597C-6525-4F00-85CB-6C6DCF165EE9</CodesignProvision>
<IpaPackageName />
<CrashReportingApiKey />
<MtouchI18n />
+ <MtouchArch>ARMv7</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>none</DebugType>
- <Optimize>true</Optimize>
+ <Optimize>True</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
+ <ConsolePause>False</ConsolePause>
<CodesignKey>iPhone Developer</CodesignKey>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
<DebugType>none</DebugType>
- <Optimize>true</Optimize>
+ <Optimize>True</Optimize>
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
- <BuildIpa>true</BuildIpa>
+ <ConsolePause>False</ConsolePause>
+ <BuildIpa>True</BuildIpa>
<CodesignKey>iPhone Distribution</CodesignKey>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
<DebugType>none</DebugType>
- <Optimize>true</Optimize>
+ <Optimize>True</Optimize>
<OutputPath>bin\iPhone\AppStore</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
+ <ConsolePause>False</ConsolePause>
<CodesignKey>iPhone Distribution</CodesignKey>
</PropertyGroup>
<ItemGroup>
@@ -36,9 +36,8 @@
<AssemblyOriginatorKeyFile>PushSharp-Signing.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Newtonsoft.Json.4.5.9\lib\net40\Newtonsoft.Json.dll</HintPath>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.4.5.10\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.5.9" targetFramework="net40" />
+ <package id="Newtonsoft.Json" version="4.5.10" targetFramework="net40" />
</packages>
@@ -43,9 +43,23 @@ public ApplePushChannel(ApplePushChannelSettings channelSettings, PushServiceSet
certificate = this.appleSettings.Certificate;
- certificates = new X509CertificateCollection();
+ certificates = new X509CertificateCollection();
+
+ if (appleSettings.AddLocalAndMachineCertificateStores)
+ {
+ var store = new X509Store(StoreLocation.LocalMachine);
+ certificates.AddRange(store.Certificates);
+
+ store = new X509Store(StoreLocation.CurrentUser);
+ certificates.AddRange(store.Certificates);
+ }
+
certificates.Add(certificate);
+ if (this.appleSettings.AdditionalCertificates != null)
+ foreach (var addlCert in this.appleSettings.AdditionalCertificates)
+ certificates.Add(addlCert);
+
//Start our cleanup task
taskCleanup = new Task(() => Cleanup(), TaskCreationOptions.LongRunning);
taskCleanup.ContinueWith((t) => { var ex = t.Exception; }, TaskContinuationOptions.OnlyOnFaulted);
@@ -65,16 +65,19 @@ void Initialize(bool production, X509Certificate2 certificate)
this.FeedbackIntervalMinutes = 10;
this.FeedbackTimeIsUTC = false;
+ this.AdditionalCertificates = new List<X509Certificate2>();
+ this.AddLocalAndMachineCertificateStores = false;
+
CheckProductionCertificateMatching(production);
}
public bool DetectProduction(X509Certificate2 certificate)
{
bool production = false;
- if (this.Certificate != null)
+ if (certificate != null)
{
- var subjectName = this.Certificate.SubjectName.Name;
+ var subjectName = certificate.SubjectName.Name;
if (subjectName.Contains("Apple Production IOS Push Services"))
production = true;
@@ -132,6 +135,18 @@ public X509Certificate2 Certificate
private set;
}
+ public List<X509Certificate2> AdditionalCertificates
+ {
+ get;
+ private set;
+ }
+
+ public bool AddLocalAndMachineCertificateStores
+ {
+ get;
+ set;
+ }
+
public bool SkipSsl
{
get;
@@ -36,9 +36,8 @@
<AssemblyOriginatorKeyFile>PushSharp-Signing.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Newtonsoft.Json.4.5.9\lib\net40\Newtonsoft.Json.dll</HintPath>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.4.5.10\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -2,4 +2,5 @@
<packages>
<package id="Newtonsoft.Json" version="4.5.6" />
<package id="Newtonsoft.Json" version="4.5.9" targetFramework="net40" />
+ <package id="Newtonsoft.Json" version="4.5.10" targetFramework="net40" />
</packages>
@@ -37,9 +37,8 @@
<AssemblyOriginatorKeyFile>PushSharp-Signing.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Newtonsoft.Json.4.5.9\lib\net40\Newtonsoft.Json.dll</HintPath>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.4.5.10\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.5.9" targetFramework="net40" />
+ <package id="Newtonsoft.Json" version="4.5.10" targetFramework="net40" />
</packages>

0 comments on commit 6494fe6

Please sign in to comment.