-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Det blir veldig verbose greier av å flytte så mange sertifikater, men skal i utgangspunktet være en veldig snill greie, så det er ikke så skummelt som det ser ut til
- Loading branch information
Aleksander Aas Sjåfjell
committed
Sep 27, 2016
1 parent
9781f1b
commit 34b0e5d
Showing
54 changed files
with
507 additions
and
419 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
Difi.Felles.Utility.Resources/Certificate/CertificateResource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System.Collections.Generic; | ||
using System.Security.Cryptography.X509Certificates; | ||
using ApiClientShared; | ||
|
||
namespace Difi.Felles.Utility.Resources.Certificate | ||
{ | ||
internal class CertificateResource | ||
{ | ||
private static readonly ResourceUtility ResourceUtility = new ResourceUtility("Difi.Felles.Utility.Resources.Certificate.Data"); | ||
|
||
internal static X509Certificate2 GetCertificate(params string[] path) | ||
{ | ||
return new X509Certificate2(ResourceUtility.ReadAllBytes(true, path), "", X509KeyStorageFlags.Exportable); | ||
} | ||
|
||
public static class UnitTests | ||
{ | ||
public static X509Certificate2 GetProduksjonsMottakerSertifikatOppslagstjenesten() | ||
{ | ||
return GetCertificate("UnitTests", "produksjonsmottakersertifikatFraOppslagstjenesten.pem"); | ||
} | ||
|
||
public static X509Certificate2 GetFunksjoneltTestmiljøMottakerSertifikatOppslagstjenesten() | ||
{ | ||
return GetCertificate("UnitTests", "testmottakersertifikatFraOppslagstjenesten.pem"); | ||
} | ||
|
||
public static X509Certificate2 NotActivatedSelfSignedTestCertificate() | ||
{ | ||
return GetCertificate("UnitTests", "NotActivatedSelfSignedBringAs.cer"); | ||
} | ||
|
||
public static X509Certificate2 GetExpiredSelfSignedTestCertificate() | ||
{ | ||
return GetCertificate("UnitTests", "ExpiredSelfSignedBringAs.cer"); | ||
} | ||
|
||
public static X509Certificate2 GetValidSelfSignedTestCertificate() | ||
{ | ||
return GetCertificate("UnitTests", "ValidSelfSignedBringAs.cer"); | ||
} | ||
|
||
public static X509Certificate2 TestIntegrasjonssertifikat() | ||
{ | ||
return GetPostenCertificate(); | ||
} | ||
|
||
public static X509Certificate2 GetEnhetstesterSelvsignertSertifikat() | ||
{ | ||
return GetCertificate("UnitTests", "difi-enhetstester.cer"); | ||
} | ||
|
||
public static X509Certificate2 GetPostenCertificate() | ||
{ | ||
return GetCertificate("UnitTests", "PostenNorgeAs.cer"); | ||
} | ||
|
||
internal static X509Certificate2 GetAvsenderEnhetstesterSertifikat() | ||
{ | ||
return EvigTestSertifikatMedPrivatnøkkel(); | ||
} | ||
|
||
internal static X509Certificate2 GetMottakerEnhetstesterSertifikat() | ||
{ | ||
return EvigTestSertifikatUtenPrivatnøkkel(); | ||
} | ||
|
||
private static X509Certificate2 EvigTestSertifikatUtenPrivatnøkkel() | ||
{ | ||
return GetCertificate("UnitTests", "difi-enhetstester.cer"); | ||
} | ||
|
||
private static X509Certificate2 EvigTestSertifikatMedPrivatnøkkel() | ||
{ | ||
return GetCertificate("UnitTests", "difi-enhetstester.p12"); | ||
} | ||
} | ||
|
||
public static class Chain | ||
{ | ||
public static List<X509Certificate2> GetDifiTestChain() | ||
{ | ||
return new List<X509Certificate2> | ||
{ | ||
new X509Certificate2(GetCertificate("TestChain", "Buypass_Class_3_Test4_CA_3.cer")), | ||
new X509Certificate2(GetCertificate("TestChain", "Buypass_Class_3_Test4_Root_CA.cer")), | ||
new X509Certificate2(GetCertificate("TestChain", "intermediate - commfides cpn enterprise-norwegian sha256 ca - test2.crt")), | ||
new X509Certificate2(GetCertificate("TestChain", "root - cpn root sha256 ca - test.crt")) | ||
}; | ||
} | ||
|
||
public static List<X509Certificate2> GetDifiProductionChain() | ||
{ | ||
return new List<X509Certificate2> | ||
{ | ||
new X509Certificate2(GetCertificate("ProdChain", "BPClass3CA3.cer")), | ||
new X509Certificate2(GetCertificate("ProdChain", "BPClass3RootCA.cer")), | ||
new X509Certificate2(GetCertificate("ProdChain", "cpn enterprise sha256 class 3.crt")), | ||
new X509Certificate2(GetCertificate("ProdChain", "cpn rootca sha256 class 3.crt")) | ||
}; | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
116 changes: 116 additions & 0 deletions
116
Difi.Felles.Utility.Resources/Difi.Felles.Utility.Resources.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{C737EA02-E687-45C4-95DB-72B5083246F2}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Difi.Felles.Utility.Resources</RootNamespace> | ||
<AssemblyName>Difi.Felles.Utility.Resources</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SignAssembly>true</SignAssembly> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<AssemblyOriginatorKeyFile>C:\Keys\digipost.pfx</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="ApiClientShared, Version=1.0.5968.19413, Culture=neutral, PublicKeyToken=683b8efceae684a6, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\api-client-shared.1.0.5968.19413\lib\net45\ApiClientShared.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\SharedAssemblyInfo.cs"> | ||
<Link>Properties\SharedAssemblyInfo.cs</Link> | ||
</Compile> | ||
<Compile Include="Certificate\CertificateResource.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Xml\Data\Transportkvittering.cs" /> | ||
<Compile Include="Xml\XmlUtility.cs" /> | ||
<Compile Include="Xml\XmlResource.cs" /> | ||
<Compile Include="Xsd\XsdResource.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Certificate\Data\UnitTests\difi-enhetstester.cer" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Certificate\Data\UnitTests\difi-enhetstester.p12" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Certificate\Data\UnitTests\ExpiredSelfSignedBringAs.cer" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Certificate\Data\UnitTests\NotActivatedSelfSignedBringAs.cer" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Certificate\Data\UnitTests\PostenNorgeAs.cer" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Certificate\Data\UnitTests\ValidSelfSignedBringAs.cer" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Certificate\Data\UnitTests\produksjonsmottakersertifikatFraOppslagstjenesten.pem" /> | ||
<EmbeddedResource Include="Certificate\Data\UnitTests\testmottakersertifikatFraOppslagstjenesten.pem" /> | ||
<EmbeddedResource Include="Certificate\Data\ProdChain\BPClass3CA3.cer" /> | ||
<EmbeddedResource Include="Certificate\Data\ProdChain\BPClass3RootCA.cer" /> | ||
<EmbeddedResource Include="Certificate\Data\ProdChain\cpn enterprise sha256 class 3.crt" /> | ||
<EmbeddedResource Include="Certificate\Data\ProdChain\cpn rootca sha256 class 3.crt" /> | ||
<EmbeddedResource Include="Certificate\Data\TestChain\Buypass_Class_3_Test4_CA_3.cer" /> | ||
<EmbeddedResource Include="Certificate\Data\TestChain\Buypass_Class_3_Test4_Root_CA.cer" /> | ||
<EmbeddedResource Include="Certificate\Data\TestChain\intermediate - commfides cpn enterprise-norwegian sha256 ca - test2.crt" /> | ||
<EmbeddedResource Include="Certificate\Data\TestChain\root - cpn root sha256 ca - test.crt" /> | ||
<None Include="packages.config" /> | ||
<EmbeddedResource Include="Xsd\Data\Sample.xsd"> | ||
<SubType>Designer</SubType> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Xml\Data\InvalidIdentifikatorContent.xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Xml\Data\UnknownElement.xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Xml\Data\Valid.xml" /> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("Difi.Felles.Utility.Resources")] | ||
[assembly: ComVisible(false)] | ||
[assembly: InternalsVisibleTo("Difi.Felles.Utility,PublicKey=00240000048000009400000006020000002400005253413100040000010001008b3388f9c416425f0145bbcf26e66b9a87c4e08b4cd41563e4bc8846df38ba4d997c5408cc77da26d79b03c39874a6af9df0aff3e7bdb3c0e53a91f6d19c50e160f5bf67986a04f0f985eca0252f557ed9ae520dd51e3107d6168d073d4ec5ada28d34e492ad9fb7af29c82309c5c0124211e679caea38d5463d2af9042dafda")] |
26 changes: 13 additions & 13 deletions
26
...tdata/Xml/InvalidIdentifikatorContent.xml → .../Xml/Data/InvalidIdentifikatorContent.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<?xml version="1.0"?> | ||
<Envelope xmlns="http://tempuri.org/po.xsd" > | ||
<Header> | ||
<Security> | ||
<InclusiveNamespaces PrefixList="" /> | ||
</Security> | ||
</Header> | ||
<Body> | ||
<Forespoersel> | ||
<Identifikator>invalidContent</Identifikator> | ||
</Forespoersel> | ||
</Body> | ||
</Envelope> | ||
<?xml version="1.0"?> | ||
<Envelope xmlns="http://tempuri.org/po.xsd" > | ||
<Header> | ||
<Security> | ||
<InclusiveNamespaces PrefixList="" /> | ||
</Security> | ||
</Header> | ||
<Body> | ||
<Forespoersel> | ||
<Identifikator>invalidContent</Identifikator> | ||
</Forespoersel> | ||
</Body> | ||
</Envelope> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0"?> | ||
<Envelope xmlns="http://tempuri.org/po.xsd"> | ||
<Header> | ||
<Security> | ||
<InclusiveNamespaces PrefixList=""/> | ||
</Security> | ||
</Header> | ||
<Body> | ||
<Forespoersel> | ||
<blabla/> | ||
</Forespoersel> | ||
</Body> | ||
</Envelope> |
32 changes: 16 additions & 16 deletions
32
...les.Utility.Tester/Testdata/Xml/Valid.xml → ...lles.Utility.Resources/Xml/Data/Valid.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<Envelope xmlns="http://tempuri.org/po.xsd" > | ||
<Header> | ||
<Security> | ||
<InclusiveNamespaces PrefixList="" /> | ||
</Security> | ||
</Header> | ||
<Body> | ||
<Forespoersel> | ||
<Identifikator>abc</Identifikator> | ||
</Forespoersel> | ||
<Forespoersel> | ||
<Identifikator>bbb</Identifikator> | ||
</Forespoersel> | ||
</Body> | ||
</Envelope> | ||
<?xml version="1.0"?> | ||
<Envelope xmlns="http://tempuri.org/po.xsd"> | ||
<Header> | ||
<Security> | ||
<InclusiveNamespaces PrefixList=""/> | ||
</Security> | ||
</Header> | ||
<Body> | ||
<Forespoersel> | ||
<Identifikator>abc</Identifikator> | ||
</Forespoersel> | ||
<Forespoersel> | ||
<Identifikator>bbb</Identifikator> | ||
</Forespoersel> | ||
</Body> | ||
</Envelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Text; | ||
using ApiClientShared; | ||
|
||
namespace Difi.Felles.Utility.Resources.Xml | ||
{ | ||
public class XmlResource | ||
{ | ||
private static readonly ResourceUtility ResourceUtility = new ResourceUtility("Difi.Felles.Utility.Resources.Xml.Data"); | ||
|
||
private static string GetResource(params string[] path) | ||
{ | ||
var bytes = ResourceUtility.ReadAllBytes(true, path); | ||
return XmlUtility.ToXmlDocument(Encoding.UTF8.GetString(bytes)).OuterXml; | ||
} | ||
|
||
internal class GetContent | ||
{ | ||
public static string GetInvalid() | ||
{ | ||
return GetResource("InvalidIdentifikatorContent.xml"); | ||
} | ||
|
||
public static string GetContentWithUnknownElement() | ||
{ | ||
return GetResource("UnknownElement.xml"); | ||
} | ||
|
||
public static string GetValid() | ||
{ | ||
return GetResource("Valid.xml"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Xml; | ||
|
||
namespace Difi.Felles.Utility.Resources.Xml | ||
{ | ||
public class XmlUtility | ||
{ | ||
public static XmlDocument ToXmlDocument(string xml) | ||
{ | ||
var xmlDocument = new XmlDocument(); | ||
xmlDocument.LoadXml(xml); | ||
|
||
return xmlDocument; | ||
} | ||
} | ||
} |
Oops, something went wrong.