Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
Merge pull request #224 from difi/bump-avhengigheter
Browse files Browse the repository at this point in the history
Bumper avhengigheter.
  • Loading branch information
johnksv authored May 11, 2020
2 parents 1076925 + 5ed4df4 commit 90e69df
Show file tree
Hide file tree
Showing 17 changed files with 961 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BouncyCastle" Version="1.8.5" />
<PackageReference Include="Difi.Felles.Utility" Version="4.0.0" />
<PackageReference Include="Digipost.Api.Client.Shared" Version="6.0.0" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.6.7" />
<PackageReference Include="Difi.Felles.Utility" Version="5.0.0" />
<PackageReference Include="Digipost.Api.Client.Shared" Version="7.0.0" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="4.7.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@


<ItemGroup>
<PackageReference Include="BouncyCastle" Version="1.8.5" />
<PackageReference Include="Difi.Felles.Utility" Version="4.0.0" />
<PackageReference Include="Digipost.Api.Client.Shared" Version="6.0.0" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.6.7" />
<PackageReference Include="Difi.Felles.Utility" Version="5.0.0" />
<PackageReference Include="Digipost.Api.Client.Shared" Version="7.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BouncyCastle" Version="1.8.5" />
<PackageReference Include="CompareNETObjects" Version="4.62.0" />
<PackageReference Include="Difi.Felles.Utility" Version="4.0.0" />
<PackageReference Include="Digipost.Api.Client.Shared" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.6.7" />
<PackageReference Include="CompareNETObjects" Version="4.66.0" />
<PackageReference Include="Difi.Felles.Utility" Version="5.0.0" />
<PackageReference Include="Digipost.Api.Client.Shared" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit.assert" Version="2.4.1" />
<PackageReference Include="xunit.core" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BouncyCastle" Version="1.8.5" />
<PackageReference Include="Difi.Felles.Utility" Version="4.0.0" />
<PackageReference Include="Digipost.Api.Client.Shared" Version="6.0.0" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.6.7" />
<PackageReference Include="Difi.Felles.Utility" Version="5.0.0" />
<PackageReference Include="Digipost.Api.Client.Shared" Version="7.0.0" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0-preview8.19405.4" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.5.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.3" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.2" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.7.0" />
</ItemGroup>
Expand Down
21 changes: 8 additions & 13 deletions Difi.SikkerDigitalPost.Klient/Utilities/LoggingUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@ internal static IServiceProvider CreateServiceProviderAndSetUpLogging()

services.AddSingleton<ILoggerFactory, LoggerFactory>();
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
services.AddLogging((builder) => builder.SetMinimumLevel(LogLevel.Trace));
services.AddLogging(builder =>
{
builder.SetMinimumLevel(LogLevel.Trace);
builder.AddNLog(new NLogProviderOptions
{CaptureMessageTemplates = true, CaptureMessageProperties = true});
NLog.LogManager.LoadConfiguration("./../../../../Difi.SikkerDigitalPost.Klient/nlog.config");
});

var serviceProvider = services.BuildServiceProvider();
SetUpLoggingForTesting(serviceProvider);

return serviceProvider;
}

private static void SetUpLoggingForTesting(IServiceProvider serviceProvider)
{
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();

loggerFactory.AddNLog(new NLogProviderOptions {CaptureMessageTemplates = true, CaptureMessageProperties = true});
NLog.LogManager.LoadConfiguration("./../../../../Difi.SikkerDigitalPost.Klient/nlog.config");
return services.BuildServiceProvider();
}

}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#Sikker Digital Post Klient Dotnet
# Sikker Digital Post Klient Dotnet

[![Build status](https://ci.appveyor.com/api/projects/status/5emuaqbxacn96p8u/branch/master?svg=true)](https://ci.appveyor.com/project/difi/sikker-digital-post-klient-dotnet/branch/master)
[![Build Status](https://travis-ci.org/difi/sikker-digital-post-klient-dotnet.svg?branch=master)](https://travis-ci.org/difi/sikker-digital-post-klient-dotnet)

Dette er en .NET-klient for sending av sikker digital post for det offentlige. Formålet for klienten er å forenkle integrasjonen
som må utføres av avsendervirksomheter. For mer informasjon om sikker digital post, se [her](http://begrep.difi.no/SikkerDigitalPost/).

#Online Dokumentasjon#
## Online Dokumentasjon
[ONLINE DOKUMENTASJON FINNER DU HER](http://difi.github.io/sikker-digital-post-klient-dotnet/)

12 changes: 9 additions & 3 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ licenseUrl: http://opensource.org/licenses/MIT
baseurl: "/sikker-digital-post-klient-dotnet"

##Version handling
currentCollecion: "v3_1"
currentVersion: "3.1"
versions: ["3.1", "3.0","2.0","1.6-1.11","1.5","1.4","1.3","1.2"]
currentCollecion: "v5_0"
currentVersion: "5.0"
versions: ["5.0","4.0","3.1", "3.0","2.0","1.6-1.11","1.5","1.4","1.3","1.2"]

# Collection of versions
collections:
Expand Down Expand Up @@ -45,6 +45,12 @@ collections:
v3_1:
output: true
permalink: /v3.1/
v4_0:
output: true
permalink: /v4.0/
v5_0:
output: true
permalink: /v5.0/
## End of Version handling

aboutSide: "about.html"
Expand Down
87 changes: 87 additions & 0 deletions docs/_v4_0/1_hvordan-komme-i-gang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
title: Hvordan komme i gang
identifier: hvordankommeigang
layout: default
description: En liten oppstart for å komme i gang.
isHome: false
---

Klienten er tilgjengelig som en NuGet-pakke. Denne vil oppdateres jevnlig etter hvert som ny funksjonalitet legges til.

For å installere NuGet-pakken, gjør følgende i Visual Studio/Rider:

1. Velg _TOOLS -> NuGet Package Manager -> Manage Nuget Packages for Solution..._
1. Søk etter _Difi.SikkerDigitalPost.Klient_. Flere pakker vil dukke opp. Installer de som er relevant for deg. Pass på å _IKKE_ installer `difi-sikker-digital-post-klient` pakken. Den er ett .NET Framework bibliotek med uheldig likt navn.
Hvis du leter etter .NET Framework dokumentasjonen, se versjon [2](http://difi.github.io/sikker-digital-post-klient-dotnet/v2/).
* Ønsker du pre-release, må du sørge for at det står _Include Prerelease_ i drop-down menyen rett over søkeresuløtatene (der det står _Stable Only_).
1. Velg _Difi.SikkerDigitalPost.Klient.X_ og trykk _Install_.


### Installer og bruk databehandlersertifikat
Som bruker av dette biblioteket er du en Databehandler som har ansvar for sending av meldinger. For å gjøre dette trenger du et sertifikat for å kunne autentisere deg mot Meldingsformidleren. Du kan lese mer om aktørene hos [begrep.difi.no](http://begrep.difi.no/SikkerDigitalPost/forretningslag/Aktorer).
Dette bør installeres på maskinen som skal bruke klientbiblioteket. Grunnen til at vi ønsker å installere det er for å ikke ha passord i klartekst i koden.

<blockquote>SSL Certificates are small data files that digitally bind a cryptographic key to an organization's details. When installed on a web server, it activates the padlock and the https protocol (over port 443) and allows secure connections from a web server to a browser.</blockquote>

For å kommunisere over HTTPS trenger du å signere dine requests med ett databehandlersertifikat. Dette sertifikatet kan lastes direkte fra en fil eller fra Windows Certificate Store.

Følgende steg vil installere sertifikatet i din Certificate Store. Dette burde gjøres på serveren hvor din applikasjon skal kjøre.

For mer informasjon, se [Microsoft Dokumentasjonen](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-2.2&tabs=windows#how-the-secret-manager-tool-works).

Filplasseringen og passord til sertifikatet må legges ett trygt sted.

Filplassering i Windows er:
```
%APPDATA%\Microsoft\UserSecrets\<user_secrets_id>\secrets.json
```

Filplassering i MacOS/Linux er:
```
~/.microsoft/usersecrets/<user_secrets_id>/secrets.json
```

Legg til følgende `UserSecretsId` element i din `.csproj` fil:
``` xml
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>enterprise-certificate</UserSecretsId>
</PropertyGroup>
```

Dette betyr at elementet `<user_secrets_id>` in the filplasseringen vil være `enterprise-certificate`.

Fra command linjen, naviger til filplassering hvor din hoved `.csproj` fil ligger og kjør følgene kommandoer med dine egne sertifikat verdier:
```
dotnet user-secrets set "Certificate:Path:Absolute" "<your-certificate.p12>"
dotnet user-secrets set "Certificate:Password" "<your-certificate-password>"
```

#### Stol på sertifikatet i Windows:
1. Dobbeltklikk på sertifikatet (Sertifikatnavn.p12)
1. Velg at sertifikatet skal lagres i `Current User` eller `Local Machine` og trykk _Next_
If you are running the client library from a system account, but debugging from a different user, please install it on `Local Machine`, as this enables loading it from any user.
1. Filnavn skal nå være utfylt. Trykk _Next_
1. Skriv inn passord for privatnøkkel og velg _Mark this key as exportable ..._, trykk _Next_
1. Velg _Automatically select the certificate store based on the type of certificate_
1. Klikk _Next_ og _Finish_
1. Får du spørsmål om å godta sertifikatkjeden så du gjør det.
1. Du skal da få en dialog som sier at importeringen var vellykket. Trykk _OK_.


#### Stol på sertifikatet i MacOS:
1. Åpne `Keychain Access`
1. Velg `login` keychain
1. Trykk på _File_ og deretter _Import_
1. Velg databehandlersertifikatet og legg den til


#### Stol på sertifikatet i Linux:
Last ned _root_ og _intermediate_ sertifikatene fra [Difi](https://begrep.difi.no/SikkerDigitalPost/1.2.6/sikkerhet/sertifikathandtering) for din databehandlersertifkat utgiver.
Merk navnendringen til å ha `.crt` på slutten for `update-ca-certificates`:

```
sudo cp Buypass_Class_3_Test4_Root_CA.pem /usr/local/share/ca-certificates/Buypass_Class_3_Test4_Root_CA.crt
sudo cp Buypass_Class_3_Test4_CA_3.pem /usr/local/share/ca-certificates/Buypass_Class_3_Test4_CA_3.crt
sudo update-ca-certificates
```
Loading

0 comments on commit 90e69df

Please sign in to comment.