Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Commit c58fc7b

Browse files
author
Mihkel Kivisild
committed
Copied instructions for adding Web eID authentication token validation library to the project from web-eid-authtoken-validation-dotnet repository.
WE2-572 Signed-off-by: Mihkel Kivisild [email protected]
1 parent 5ec8361 commit c58fc7b

File tree

1 file changed

+55
-32
lines changed

1 file changed

+55
-32
lines changed

README.md

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,71 @@ The ASP.NET web application makes use of the following technologies:
1313
- the Web eID JavaScript library [_web-eid.js_](https://github.com/web-eid/web-eid.js),
1414
- the digital signing library [_libdigidocpp_](https://github.com/open-eid/libdigidocpp/tree/master/examples/DigiDocCSharp).
1515

16-
Note that for including the Web eID authentication token validation library as a nuget package you need to have added a Package Source with the following address to the NuGet Package Manager:
17-
https://gitlab.com/api/v4/projects/35362906/packages/nuget/index.json
18-
1916
## Quickstart
2017

2118
Complete the steps below to run the example application in order to test authentication and digital signing with Web eID.
2219

23-
### 1. Configure the origin URL
20+
### 1. Add the Web eID authentication token validation library to your project
21+
22+
#### When using Visual Studio
23+
24+
1. Configure Web eID GitLab package repository as a NuGet package source.
25+
In MS Visual Studio, go to the **Tools** > **NuGet Package Manager** > **Package Manager Settings** menu command. Select **Package Sources** and add a new source. Name it _Web eID GitLab_ and set the _Source_ URL to `https://gitlab.com/api/v4/projects/35362906/packages/nuget/index.json`.
26+
27+
2. Install the `WebEid.Security` NuGet package.
28+
You can install the package either from the GUI or the Package Manager Console.
29+
30+
- From GUI:
31+
Right-click the project in the Solution Explorer where you want to install the Web eID dependency. Select **Manage NuGet Packages**. Choose the _Web eID GitLab_ package source you added earlier from the _Package source_ dropdown. Then, install the `WebEid.Security` package.
32+
33+
34+
- From Package Manager Console:
35+
Run the following command:
36+
```
37+
Install-Package WebEid.Security
38+
```
39+
40+
#### When using `dotnet` CLI
41+
42+
In case you prefer using command line tools, you can add the package using the `dotnet` CLI with the following command:
43+
44+
```
45+
dotnet add package WebEid.Security --source https://gitlab.com/api/v4/projects/35362906/packages/nuget/index.json
46+
```
47+
48+
**Note:** When you install a package, NuGet records the dependency in either your project file or a `packages.config` file, depending on the selected package management format (`Packages.config` or `PackageReference`).
49+
50+
For more detailed information on different methods of installing NuGet packages, refer to [Microsoft's official documentation](https://learn.microsoft.com/en-us/nuget/consume-packages/overview-and-workflow#ways-to-install-a-nuget-package).
51+
52+
### 2. Configure the origin URL
2453
2554
One crucial step of the Web eID authentication token validation algorithm is verifying the token signature. The value that is signed contains the site origin URL (the URL serving the web application) to protect against man-in-the-middle attacks. Hence the site origin URL must be configured in application settings.
2655
27-
To configure the origin URL, add `OriginUrl` field in the application settings file `appsettings.json` as follows:
56+
To configure the origin URL, add `OriginUrl` field in the application settings file in either `appsettings.Development.json` for `Development` profile or `appsettings.json` for `Production` profile as follows:
2857
```json
2958
{
3059
"OriginUrl": "https://example.org"
3160
}
3261
```
33-
Note that the URL **must not end with a slash** `/`.
62+
Note that the URL **must not end with a slash** `/` and the URL must be the same as the `applicationUrl` in `launchSettings.json`. When you change the `OriginUrl`, also change the `applicationUrl` in `launchSettings.json`.
3463

35-
### 2. Configure the trusted certificate authority certificates
64+
### 3. Configure the trusted certificate authority certificates
3665

37-
The algorithm, which performs the validation of the Web eID authentication token, needs to know which intermediate certificate authorities (CA) are trusted to issue the eID authentication certificates. CA certificates are loaded from `.cer` files in the profile-specific subdirectory of the [`Certificates` resource directory](https://github.com/web-eid/web-eid-asp-dotnet-example/src/WebEid.AspNetCore.Example/Certificates). By default, Estonian eID test CA certificates are included in the `Development` profile and production CA certificates in the `Production` profile.
66+
The algorithm, which performs the validation of the Web eID authentication token, needs to know which intermediate certificate authorities (CA) are trusted to issue the eID authentication certificates. CA certificates are loaded from `.cer` files in the profile-specific subdirectory of the [`Certificates` resource directory](https://github.com/web-eid/web-eid-asp-dotnet-example/tree/main/src/WebEid.AspNetCore.Example/Certificates). By default, Estonian eID test CA certificates are included in the `Development` profile and production CA certificates in the `Production` profile.
3867

3968
In case you need to provide your own CA certificates, add the `.cer` files to the `src/WebEid.AspNetCore.Example/Certificates/{Dev,Prod}` profile-specific directory.
4069

41-
### 3. Setup the `libdigidocpp` library for signing
70+
### 4. Setup the `libdigidocpp` library for signing
4271

4372
`libdigidocpp` is a library for creating, signing and verifying digitally signed documents according to XAdES and XML-DSIG standards. It is a C++ library that has [SWIG](http://swig.org/) bindings for C#.
4473

4574
Set up the `libdigidocpp` library as follows:
4675

4776
#### For MS Windows
4877

49-
1. Install the _libdigidocpp-3.17.1.msi_ package or higher. The installation packages are available from [https://github.com/open-eid/libdigidocpp/releases](https://github.com/open-eid/libdigidocpp/releases).
78+
1. Install the _libdigidocpp-4.0.0.8301.x64.msi_ package or higher. The installation packages are available from [https://github.com/open-eid/libdigidocpp/releases](https://github.com/open-eid/libdigidocpp/releases).
5079
2. Copy the C# source files from the `libdigidocpp` installation folder `include\digidocpp_csharp` to the `src\WebEid.AspNetCore.Example\DigiDoc` folder.
51-
3. Copy all files from either the `x64` subfolder of the `libdigidocpp` installation folder to the example application build output folder `bin\...\net8.0` (after building, see next step). When building custom applications, choose `x64` if your application is 64-bit and `x86` if it is 32-bit.
80+
3. Copy all files from the `libdigidocpp` installation folder to the example application build output folder `bin\Debug\net8.0` (after building, see next step).
5281
4. When running in the `Development` profile, create an empty file named `EE_T.xml` for TSL cache as described in the [_Using test TSL lists_](https://github.com/open-eid/libdigidocpp/wiki/Using-test-TSL-lists#preconditions) section of the `libdigidocpp` wiki.
5382

5483
#### For Ubuntu Linux
@@ -72,51 +101,49 @@ Set up the `libdigidocpp` library as follows:
72101
4. Copy the necessary DigiDoc C# library files into your project:
73102

74103
```sh
75-
cp /usr/include/digidocpp_csharp/* WebEid.AspNetCore.Example/DigiDoc/
104+
cp /usr/include/digidocpp_csharp/* /usr/lib/x86_64-linux-gnu/libdigidoc_csharp.so WebEid.AspNetCore.Example/DigiDoc/
76105
```
77106

78107
#### For macOS
79108

80-
1. Install the _libdigidocpp-3.17.1.pkg_ package or higher. The installation packages are available from [https://github.com/open-eid/libdigidocpp/releases](https://github.com/open-eid/libdigidocpp/releases).
109+
1. Install the *libdigidocpp_4.0.0.1460.pkg* package or higher. The installation packages are available from [https://github.com/open-eid/libdigidocpp/releases](https://github.com/open-eid/libdigidocpp/releases).
81110
2. Copy the C# source files from `/Library/libdigidocpp/include/digidocpp_csharp` directory to `src/WebEid.AspNetCore.Example/DigiDoc` directory.
82-
3. Go to `src/WebEid.AspNetCore.Example/bin/.../net8.0` directory and create symbolic link to `/Library/libdigidocpp/lib/libdigidoc_csharp.dylib` library:
111+
3. Go to `bin/Debug/net8.0` directory and create symbolic link to `/Library/libdigidocpp/lib/libdigidoc_csharp.dylib` library:
83112
```cmd
84113
ln -s /Library/libdigidocpp/lib/libdigidoc_csharp.dylib
85114
```
86115

87116
Further information is available in the [libdigidocpp example C# application source code](https://github.com/open-eid/libdigidocpp/tree/master/examples/DigiDocCSharp) and in the [`libdigidocpp` Wiki](https://github.com/open-eid/libdigidocpp/wiki).
88117

89-
### 4. Build the application
118+
### 5. Build the application
90119

91-
You need to have the [.NET 6.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) installed for building the application package.
120+
You need to have the [.NET 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) installed for building the application package.
92121
Build the application by running the following command in a terminal window under the `src` directory:
93122

94123
```cmd
95124
dotnet build
96125
```
97126

98-
### 5. Choose either the `Development` or `Production` profile
127+
### 6. Choose either the `Development` or `Production` profile
99128

100129
If you have a test eID card, use the `Development` profile. In this case access to paid services is not required, but you need to upload the authentication and signing certificates of the test card to the test OCSP responder database as described in section _[Using DigiDoc4j in test mode with the `dev` profile](https://github.com/web-eid/web-eid-spring-boot-example#using-digidoc4j-in-test-mode-with-the-dev-profile)_ of the Web eID Java example application documentation. The`Development` profile is activated by default.
101130

102131
If you only have a production eID card, i.e. an eID card issued to a real person or organization, use the `Production` profile. You can still test authentication without further configuration; however, for digital signing to work, you need access to a paid timestamping service as described in section [_Using DigiDoc4j in production mode with the `prod` profile_](https://github.com/web-eid/web-eid-spring-boot-example#using-digidoc4j-in-production-mode-with-the-prod-profile) of the Web eID Java example documentation.
103132

104-
You can specify the profile as an environment variable `ASPNETCORE_ENVIRONMENT` when running the application. To set the profile for the current session before starting the app using [`dotnet run`](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-run), use the following command:
105-
```cmd
106-
set ASPNETCORE_ENVIRONMENT=Production
107-
```
133+
You can specify the profile as an environment variable `ASPNETCORE_ENVIRONMENT` when running the application. To set the profile for the current session before starting the app using dotnet run, edit the appropriate profile in the `launchSettings.json` file located at `src/WebEid.AspNetCore.Example/Properties/`. Modify the `environmentVariables` section in the `launchSettings.json` file by setting the `ASPNETCORE_ENVIRONMENT` to `Production`.
108134

109-
### 6. Run the application
135+
### 7. Run the application
110136

111137
Run the application with the following command in a terminal window under the `src` directory:
112138

113139
```cmd
114140
dotnet run --project WebEid.AspNetCore.Example
115141
```
116142

117-
This will activate the default `Development` profile and launch the built-in `kestrel` web server on HTTPS port 5001.
143+
This will activate the `https` profile in the `launchSettings.json` and launch the built-in `kestrel` web server on the defined `applicationUrl`.
118144

119-
When the application has started, open https://localhost:5001 in your preferred web browser and follow instructions on the front page.
145+
When the application has started, open your preferred web browser on the address defined in `launchSettings.json` on the `applicationUrl` field at `https` profile and follow instructions on the front page.
146+
By default the address is https://localhost:44391.
120147

121148
## Overview of the source code
122149

@@ -129,7 +156,7 @@ The `src\WebEid.AspNetCore.Example` directory contains the ASP.NET application s
129156
- digital signing,
130157
- `DigiDoc`: contains the C# binding files of the `libdigidocpp` library; these files must be copied from the `libdigidocpp` installation directory `\include\digidocpp_csharp`,
131158
- `Pages`: Razor pages,
132-
- `Services`: Web eID signing service implementation that uses `libdigidocpp`.
159+
- `Signing`: Web eID signing service implementation that uses `libdigidocpp`.
133160

134161
## More information
135162

@@ -141,10 +168,6 @@ See the [Web eID Java example application documentation](https://github.com/web-
141168

142169
You are running in the `Development` profile, but you have not created an empty file named `EE_T.xml` for TSL cache. Creating the file is mandatory and is described in more detail in the [_Using test TSL lists_](https://github.com/open-eid/libdigidocpp/wiki/Using-test-TSL-lists#preconditions) section of the `libdigidocpp` wiki.
143170

144-
#### Why do I get the `System.BadImageFormatException: An attempt was made to load a program with an incorrect format` error during signing?
145-
146-
You are using `libdigidocpp` DLLs for the wrong architecture. Copy files from the `x64` subfolder of the `libdigidocpp` installation folder to right place as described in the section _3. Setup the `libdigidocpp` library for signing_ above. In case you get this error while developing a custom 32-bit application, copy files from the `x86` subfolder instead.
147-
148171
## Building and running with Docker on Ubuntu Linux
149172

150173
This section covers the steps required to build the application on an Ubuntu Linux environment and run it using Docker.
@@ -153,13 +176,13 @@ This section covers the steps required to build the application on an Ubuntu Lin
153176

154177
Before you begin, ensure you have the following installed on your system:
155178

156-
- .NET SDK 7.0
179+
- .NET SDK 8.0
157180
- libdigidocpp-csharp
158181

159182
You can install them using the following command:
160183

161184
```sh
162-
sudo apt install dotnet-sdk-7.0 libdigidocpp-csharp
185+
sudo apt install dotnet-sdk-8.0 libdigidocpp-csharp
163186
```
164187

165188
Note: Before installing `libdigidocpp-csharp` you have to have added the RIA repository as a package source. See [For Ubuntu Linux section](#for-ubuntu-linux) for information.
@@ -177,7 +200,7 @@ To build the application, follow these steps:
177200
2. Copy the necessary DigiDoc C# library files into your project:
178201

179202
```sh
180-
cp /usr/include/digidocpp_csharp/* WebEid.AspNetCore.Example/DigiDoc/
203+
cp /usr/include/digidocpp_csharp/* /usr/lib/x86_64-linux-gnu/libdigidoc_csharp.so WebEid.AspNetCore.Example/DigiDoc/
181204
```
182205

183206
3. Publish the application with the Release configuration:

0 commit comments

Comments
 (0)