Skip to content

Commit b99ea24

Browse files
authored
Merge pull request #231 from Engineering-Research-and-Development/develop
Develop - 1.14.4 release
2 parents 7dc5378 + aa179e1 commit b99ea24

File tree

5 files changed

+95
-11
lines changed

5 files changed

+95
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [1.14.4] - 2023-10-05
5+
6+
### Changed
7+
8+
- Fix extended validation bug
9+
410
## [1.14.3] - 2023-09-12
511

612
### Changed

doc/SECURITY.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Securing Connector Endpoints
22

3+
Security in Basic DataApp is implemented via Spring Security mechanism. This framework is responsible for login user and also for response headers.
4+
5+
SpringSecurity:
6+
7+
```
8+
.headers().xssProtection().and().contentTypeOptions().and().frameOptions().sameOrigin()
9+
```
10+
11+
Example for the response headers are:
12+
13+
```
14+
X-Content-Type-Options: nosniff
15+
X-XSS-Protection: 1; mode=block
16+
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
17+
X-Frame-Options: SAMEORIGIN
18+
```
319

420
Execution Core Container (and TRUE Connector) has implemented basic security mechanisms for all "public" endpoints (those endpoints that will be reached from outside world).
521

doc/TRANSPORTCERTSSHA256.md

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ header:
1313
payload:
1414
{
1515
"aud": "idsc:IDS_CONNECTORS_ALL",
16-
"iss": "https://daps.aisec.fraunhofer.de",
16+
"iss": "https://omejdn/auth,
1717
"sub": "54:3D:3A:3A:FC:DC:05:AB:88:60:9E:60:36:54keyid:CB:8C:C7:B6:85:79:A8:23:A6:CB:15:AB:17:50",
1818
"nbf": 1674038398,
1919
"iat": 1674038398,
2020
"jti": "MTQ4MDUzNTQ0NjQ3OTcxNzcxMjI=",
2121
"exp": 1674041998,
2222
"client_id": "54:3D:3A:3A:FC:DC:05:AB:88:60:9E:60:36:54keyid:CB:8C:C7:B6:85:79:A8:23:A6:CB:15:AB:17:50",
2323
"securityProfile": "idsc:BASE_SECURITY_PROFILE",
24-
"referringConnector": "http://ecc-consumer.demo",
24+
"referringConnector": "http://ecc-consumer",
2525
"@type": "ids:DatPayload",
2626
"@context": "https://w3id.org/idsa/contexts/context.jsonld",
2727
"transportCertsSha256": "a3cd813e1510ca64a9da****",
@@ -31,14 +31,72 @@ payload:
3131
}
3232
```
3333

34-
## Prerequisite
35-
For extended token validation is that **public keys from connector itself and other connectors MUST be loaded into truststore.** Reason for this is that TRUE Connector will, during startup:
34+
## Prerequisite
35+
36+
For extended token validation **public keys from connector itself and other connectors MUST be loaded into truststore.** Reason for this is that TRUE Connector will, during startup:
3637
- load all certificates from truststore
3738
- generate hash from certificate, using *MessageDigest* class.
3839
- use certificate's SubjectAlternativeName and populate map with SAN and hash. This map will later be used to perform extended jwToken validation.
3940

40-
From our example, TLS certificate should be for DNS domain with name *ecc-consumer.demo*, and when hash is calculated from certificate, it should be a3cd813e1510ca64a9da\**\**. Those 2 values will be put in map, like key-pair (ecc-consumer.demo, a3cd813e1510ca64a9da\**\**), that will be used in verify token phase.
41-
41+
From our example, TLS certificate should be for DNS domain with name *ecc-consumer*, and when hash is calculated from certificate, it should be a3cd813e1510ca64a9da\**\**. Those 2 values will be put in map, like key-pair (ecc-consumer, a3cd813e1510ca64a9da\**\**), that will be used in verify token phase.
42+
43+
### Setup and configure ECC and DAPS for extended token validation from scratch
44+
45+
In order to properly configure the extended token validation, there are a few steps that should be done:
46+
47+
1. Clone some of MVD Certification Authority (e.g. Testbed or any other Testbed based)
48+
49+
2. Go to /CertificateAuthority and generate key pair for device certificate (ECC) with the next command:
50+
51+
```
52+
python pki.py cert create --subCA ReferenceTestbedSubCA --common-name ecc-consumer --algo rsa --bits 2048 --hash sha256 --country-name ES --organization-name SQS --unit-name TestLab --server --client --san-name ecc-consumer
53+
```
54+
55+
3. Go to /CertificateAuthority/data/cert and generate p12 file which will be used in ECC as DAPS keystore with the following command:
56+
57+
```
58+
openssl pkcs12 -export -out ecc-consumer.p12 -inkey ecc-consumer.key -in ecc-consumer.crt -certfile ../ca/ReferenceTestbedCA.crt
59+
60+
```
61+
For password insert: ***password***
62+
63+
4. Copy generated p12 file to true-connector/ecc_cert and change next properties in .env file:
64+
65+
```
66+
### CONSUMER Configuration
67+
CONSUMER_DAPS_KEYSTORE_NAME=ecc-consumer.p12
68+
CONSUMER_DAPS_KEYSTORE_PASSWORD=password
69+
CONSUMER_DAPS_KEYSTORE_ALIAS=1
70+
```
71+
72+
5. Import ***ecc-consumer.crt*** to ***truststoreEcc.jks***
73+
74+
6. Register new connector in DAPS
75+
76+
**NOTE** Subject Alternative Name (SAN) which was used in the certificate creation in previous step, MUST match with client name that is used to register certificate/connector to the DAPS in register_connector.sh script.
77+
78+
6.1. Copy previously generated ecc-consumer.cert in IDS-testbed/DAPS/Keys and rename it from ***ecc-consumer.crt*** -> ***ecc-consumer.cert***
79+
80+
6.2. Go to /DAPS/ and run the following command which will register ECC as new client in client.yml:
81+
82+
6.3 Make sure that script (*register_connector.sh*) will not append additional name (like .demo) for referring connector
83+
84+
```
85+
- key: referringConnector
86+
value: http://${CLIENT_NAME}
87+
```
88+
89+
Once confirmed, following command can be executed:
90+
91+
```
92+
./register_connector.sh ecc-consumer
93+
94+
```
95+
96+
**IMPORTANT:** Repeat the same procedure for ECC Provider, and in all places instead of consumer use provider, e.g. ecc-provider.cert, etc.
97+
98+
The same steps applies for all other connectors.
99+
42100
## Validate jwToken
43101

44102
Once jwToken is received, either from DAPS or from other connector, it will be validated with following:
@@ -56,14 +114,13 @@ application.extendedTokenValidation=true
56114

57115

58116
Extended validation will do the following:
59-
- get *referringConnector* claim (in our example - "http://ecc-consumer.demo")
60-
- get *transportCertsSha256* (in our example - "a3cd813e1510ca64a9da****")
117+
- get *referringConnector* claim (in our example - "http://ecc-consumer")
118+
- get *transportCertsSha256* (in our example - "a3cd813e1510ca64a9da****") - this one will require TLS certificate loaded previously in truststore, like stated at the begining of this document (this is mandatory also for TLS communication and enabling https traffic)
61119
- check if map contains same hash value for referringConnector
62120

63121
In our example, map should contain key-pair like following (populated in startup phase):
64122

65-
(ecc-consumer.demo, a3cd813e1510ca64a9da****)
123+
(ecc-consumer, a3cd813e1510ca64a9da****)
66124

67125
If this evaluates as true, token is valid, otherwise, token is not valid.
68-
69126

src/main/java/it/eng/idsa/businesslogic/configuration/CertificationCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class CertificationCheck {
1616

1717
private static final Logger logger = LoggerFactory.getLogger(CertificationCheck.class);
1818

19-
private static final String[] CERTIFIED_VERSION = { "1.14.3" };
19+
private static final String[] CERTIFIED_VERSION = { "1.14.4" };
2020
@PostConstruct
2121
public void checkIfVerionsIsCertified() {
2222
String version = Objects.requireNonNullElse(Application.class.getPackage().getImplementationVersion(), "");

src/main/java/it/eng/idsa/businesslogic/service/impl/TransportCertsManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,17 @@ public class TransportCertsManager {
4040
public TransportCertsManager(TLSProvider tlsProvider) {
4141
this.tlsProvider = tlsProvider;
4242
populateTransportCertsSha();
43+
setConnectorTransportCertSha();
4344
}
4445

4546
public String getConnectorTransportCertsSha() {
4647
return this.connectorTransportCertSha;
4748
}
4849

50+
private void setConnectorTransportCertSha() {
51+
this.connectorTransportCertSha = getCertificateDigest(tlsProvider.getTLSKeystoreCertificate());
52+
}
53+
4954
public boolean isTransportCertValid(String connectorId, String transportCert) {
5055
logger.info("Validating transportCertSha256 for connector");
5156
return transportCert.equals(transportCerts.get(connectorId));

0 commit comments

Comments
 (0)