You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: example/README.md
+61-32Lines changed: 61 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,42 +13,77 @@ The ASP.NET web application makes use of the following technologies:
13
13
- the Web eID JavaScript library [_web-eid.js_](https://github.com/web-eid/web-eid.js),
14
14
- the digital signing library [_libdigidocpp_](https://github.com/open-eid/libdigidocpp/tree/master/examples/DigiDocCSharp).
15
15
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:
Complete the steps below to run the example application in order to test authentication and digital signing with Web eID.
22
19
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:
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
24
59
25
60
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.
26
61
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:
28
63
```json
29
64
{
30
65
"OriginUrl": "https://example.org"
31
66
}
32
67
```
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`.
34
69
35
-
### 2. Configure the trusted certificate authority certificates
70
+
### 3. Configure the trusted certificate authority certificates
36
71
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.
38
73
39
74
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.
40
75
41
-
### 3. Setup the `libdigidocpp` library for signing
76
+
### 4. Setup the `libdigidocpp` library for signing
42
77
43
78
`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#.
44
79
45
80
Set up the `libdigidocpp` library as follows:
46
81
47
82
#### For MS Windows
48
83
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).
50
85
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).
52
87
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.
53
88
54
89
#### For Ubuntu Linux
@@ -72,51 +107,49 @@ Set up the `libdigidocpp` library as follows:
72
107
4. Copy the necessary DigiDoc C# library files into your project:
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).
81
116
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:
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).
88
123
89
-
### 4. Build the application
124
+
### 5. Build the application
90
125
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.
92
127
Build the application by running the following commandin a terminal window under the `src` directory:
93
128
94
129
```cmd
95
130
dotnet build
96
131
```
97
132
98
-
### 5. Choose either the `Development` or `Production` profile
133
+
### 6. Choose either the `Development` or `Production` profile
99
134
100
135
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.
101
136
102
137
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.
103
138
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 forthe current session before starting the app using dotnet run, edit the appropriate profilein 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`.
108
140
109
-
### 6. Run the application
141
+
### 7. Run the application
110
142
111
143
Run the application with the following commandin a terminal window under the `src` directory:
112
144
113
145
```cmd
114
146
dotnet run --project WebEid.AspNetCore.Example
115
147
```
116
148
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`.
118
150
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.
120
153
121
154
## Overview of the source code
122
155
@@ -129,7 +162,7 @@ The `src\WebEid.AspNetCore.Example` directory contains the ASP.NET application s
129
162
- digital signing,
130
163
- `DigiDoc`: contains the C# binding files of the `libdigidocpp` library; these files must be copied from the `libdigidocpp` installation directory `\include\digidocpp_csharp`,
131
164
- `Pages`: Razor pages,
132
-
- `Services`: Web eID signing service implementation that uses `libdigidocpp`.
165
+
- `Signing`: Web eID signing service implementation that uses `libdigidocpp`.
133
166
134
167
## More information
135
168
@@ -141,10 +174,6 @@ See the [Web eID Java example application documentation](https://github.com/web-
141
174
142
175
You are running in the `Development` profile, but you have not created an empty file named `EE_T.xml`forTSL cache. Creating the file is mandatory and is describedin 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.
143
176
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 forthe wrong architecture. Copy files from the `x64` subfolder of the `libdigidocpp` installation folder to right place as describedin 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
-
148
177
## Building and running with Docker on Ubuntu Linux
149
178
150
179
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
153
182
154
183
Before you begin, ensure you have the following installed on your system:
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:
177
206
2. Copy the necessary DigiDoc C# library files into your project:
0 commit comments