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

Commit 8e541f3

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 8e541f3

File tree

1 file changed

+61
-32
lines changed

1 file changed

+61
-32
lines changed

README.md

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,77 @@ 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 source using the `dotnet` CLI with the following command:
43+
44+
```
45+
dotnet nuget add source https://gitlab.com/api/v4/projects/35362906/packages/nuget/index.json --name "Web eID GitLab"
46+
```
47+
48+
And then in `src` folder run the following command to ensure all packages are installed:
49+
50+
```
51+
dotnet restore WebEid.AspNetCore.Example.sln
52+
```
53+
54+
**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`).
55+
56+
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).
57+
58+
### 2. Configure the origin URL
2459
2560
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.
2661
27-
To configure the origin URL, add `OriginUrl` field in the application settings file `appsettings.json` as follows:
62+
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:
2863
```json
2964
{
3065
"OriginUrl": "https://example.org"
3166
}
3267
```
33-
Note that the URL **must not end with a slash** `/`.
68+
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`.
3469

35-
### 2. Configure the trusted certificate authority certificates
70+
### 3. Configure the trusted certificate authority certificates
3671

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.
72+
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.
3873

3974
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.
4075

41-
### 3. Setup the `libdigidocpp` library for signing
76+
### 4. Setup the `libdigidocpp` library for signing
4277

4378
`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#.
4479

4580
Set up the `libdigidocpp` library as follows:
4681

4782
#### For MS Windows
4883

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).
84+
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).
5085
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.
86+
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).
5287
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.
5388

5489
#### For Ubuntu Linux
@@ -72,51 +107,49 @@ Set up the `libdigidocpp` library as follows:
72107
4. Copy the necessary DigiDoc C# library files into your project:
73108

74109
```sh
75-
cp /usr/include/digidocpp_csharp/* WebEid.AspNetCore.Example/DigiDoc/
110+
cp /usr/include/digidocpp_csharp/* /usr/lib/x86_64-linux-gnu/libdigidoc_csharp.so WebEid.AspNetCore.Example/DigiDoc/
76111
```
77112

78113
#### For macOS
79114

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).
115+
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).
81116
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:
117+
3. Go to `bin/Debug/net8.0` directory and create symbolic link to `/Library/libdigidocpp/lib/libdigidoc_csharp.dylib` library:
83118
```cmd
84119
ln -s /Library/libdigidocpp/lib/libdigidoc_csharp.dylib
85120
```
86121

87122
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).
88123

89-
### 4. Build the application
124+
### 5. Build the application
90125

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.
126+
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.
92127
Build the application by running the following command in a terminal window under the `src` directory:
93128

94129
```cmd
95130
dotnet build
96131
```
97132

98-
### 5. Choose either the `Development` or `Production` profile
133+
### 6. Choose either the `Development` or `Production` profile
99134

100135
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.
101136

102137
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.
103138

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-
```
139+
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`.
108140

109-
### 6. Run the application
141+
### 7. Run the application
110142

111143
Run the application with the following command in a terminal window under the `src` directory:
112144

113145
```cmd
114146
dotnet run --project WebEid.AspNetCore.Example
115147
```
116148

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

119-
When the application has started, open https://localhost:5001 in your preferred web browser and follow instructions on the front page.
151+
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.
152+
By default the address is https://localhost:44391.
120153

121154
## Overview of the source code
122155

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

134167
## More information
135168

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

142175
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.
143176

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-
148177
## Building and running with Docker on Ubuntu Linux
149178

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

154183
Before you begin, ensure you have the following installed on your system:
155184

156-
- .NET SDK 7.0
185+
- .NET SDK 8.0
157186
- libdigidocpp-csharp
158187

159188
You can install them using the following command:
160189

161190
```sh
162-
sudo apt install dotnet-sdk-7.0 libdigidocpp-csharp
191+
sudo apt install dotnet-sdk-8.0 libdigidocpp-csharp
163192
```
164193

165194
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 +206,7 @@ To build the application, follow these steps:
177206
2. Copy the necessary DigiDoc C# library files into your project:
178207

179208
```sh
180-
cp /usr/include/digidocpp_csharp/* WebEid.AspNetCore.Example/DigiDoc/
209+
cp /usr/include/digidocpp_csharp/* /usr/lib/x86_64-linux-gnu/libdigidoc_csharp.so WebEid.AspNetCore.Example/DigiDoc/
181210
```
182211

183212
3. Publish the application with the Release configuration:

0 commit comments

Comments
 (0)