-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
La negoziazione di un token in modalità 'SignedJWT' utilizzando un keystore di tipo 'JWK Set' falliva con il seguente errore: "Errore avvenuto durante la consegna HTTP: (Errore di Connessione) JWT Signature keystore password undefined".
- Loading branch information
1 parent
90e3697
commit f26f025
Showing
19 changed files
with
533 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
2022-12-09 Andrea Poli <[email protected]> | ||
|
||
* [GovWayCore] | ||
Risolto Bug OP-1517 | ||
La negoziazione di un token in modalità 'SignedJWT' utilizzando un keystore di tipo 'JWK Set' falliva con il seguente errore: | ||
"Errore avvenuto durante la consegna HTTP: (Errore di Connessione) JWT Signature keystore password undefined". | ||
|
||
2022-12-09 Andrea Poli <[email protected]> | ||
|
||
* [GovWayCore, Utils] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Generazione delle chiavi di test utilizzate poi nelle configurazioni: | ||
|
||
openssl genrsa -passout pass:123456 -out testJWKrsaprivkey.pem 2048 | ||
openssl rsa -in testJWKrsaprivkey.pem -pubout -outform DER -out testJWKrsapubkey.der | ||
openssl rsa -in testJWKrsaprivkey.pem -pubout -outform PEM -out testJWKrsapubkey.pem | ||
openssl pkcs8 -topk8 -inform PEM -outform DER -in testJWKrsaprivkey.pem -out testJWKrsaprivkey.der -nocrypt | ||
|
||
Dalle chiave pubbliche e private sopra, è possibile generare i corrispettivi jwks utilizzando il convertitore online in https://8gwifi.org/jwkconvertfunctions.jsp | ||
Attenzione che il json ottenuto non è all'interno di una struttura keys e quindi va inserito all'interno: | ||
{"keys":[ JSON_OTTENUTO ]} | ||
|
||
In alternativa è possibile utilizzare i comandi seguenti: | ||
|
||
java -classpath openspcoop2_utils_BUILD-90e36977.jar:lib/security/*:lib/cxf/*:lib/jackson/*:lib/swagger/* org.openspcoop2.utils.certificate.JWKPublicKeyConverter testJWKrsapubkey.der testJWKpublic.jwk true false | ||
|
||
java -classpath openspcoop2_utils_BUILD-90e36977.jar:lib/security/*:lib/cxf/*:lib/jackson/*:lib/swagger/* org.openspcoop2.utils.certificate.JWKPrivateKeyConverter testJWKrsapubkey.der testJWKrsaprivkey.der testJWKprivate.jwk true false | ||
|
1 change: 1 addition & 0 deletions
1
protocolli/trasparente/testsuite/karate/jwks/testJWKprivate.jwk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"keys":[{"p":"60kazg7hflRrvf4B4M4-j_Kqs0CKFucwF5bTEblnAylSSV8IUIp3CCKev67VmB6vGqdfTe2jMPKlksVVjCz6BWL5uLiqdzT_v9Ok9HuV3SwwvcR7bNSqPAfrZ1Gzbz9KPH80ylk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mID-S3TJHc86YlyyXB4iKbxGUKaOlL8i8jnlWU1QPgxgDMJgdKWSOuTScHTzzSBxbMLy8","n":"uO0lSzNdA4G084FnllC1gIZIWPBG5oGPC2XnsWWpw0Hw2dzo5e5nYzXGS9CChVRN6CPrybeksNuVAg8_RzCF1ZJmDCCkQeocNmrB0HhXJVLgLU3Bo4XZw_2G4zxo8RpemhyL2b3PzxplpKsmrIDI1TaCEgcvlsvmF6muMTmF9hnboGyXkapbrvVrxzU_WqZb580FzAFGyzSDNvUpIhl21k6An21jzwTQUS-M8hbXbbyO7SwMXlltbP0R1KYozBnxbfZyLlzIfw3ekuLqvjsRT68Ohej9WE3bCBKLJ2Bon7gpCgk0YaHlvGm6Dsa9E_kzWqoMurYMTPbhqCHbER5Y8w"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"keys":[{"kty":"RSA","e":"AQAB","kid":"c98fda52-9a37-41c0-8696-65e5022e9e44","n":"uO0lSzNdA4G084FnllC1gIZIWPBG5oGPC2XnsWWpw0Hw2dzo5e5nYzXGS9CChVRN6CPrybeksNuVAg8_RzCF1ZJmDCCkQeocNmrB0HhXJVLgLU3Bo4XZw_2G4zxo8RpemhyL2b3PzxplpKsmrIDI1TaCEgcvlsvmF6muMTmF9hnboGyXkapbrvVrxzU_WqZb580FzAFGyzSDNvUpIhl21k6An21jzwTQUS-M8hbXbbyO7SwMXlltbP0R1KYozBnxbfZyLlzIfw3ekuLqvjsRT68Ohej9WE3bCBKLJ2Bon7gpCgk0YaHlvGm6Dsa9E_kzWqoMurYMTPbhqCHbER5Y8w"}]} |
Binary file not shown.
27 changes: 27 additions & 0 deletions
27
protocolli/trasparente/testsuite/karate/jwks/testJWKrsaprivkey.pem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEowIBAAKCAQEAuO0lSzNdA4G084FnllC1gIZIWPBG5oGPC2XnsWWpw0Hw2dzo | ||
5e5nYzXGS9CChVRN6CPrybeksNuVAg8/RzCF1ZJmDCCkQeocNmrB0HhXJVLgLU3B | ||
o4XZw/2G4zxo8RpemhyL2b3PzxplpKsmrIDI1TaCEgcvlsvmF6muMTmF9hnboGyX | ||
kapbrvVrxzU/WqZb580FzAFGyzSDNvUpIhl21k6An21jzwTQUS+M8hbXbbyO7SwM | ||
XlltbP0R1KYozBnxbfZyLlzIfw3ekuLqvjsRT68Ohej9WE3bCBKLJ2Bon7gpCgk0 | ||
YaHlvGm6Dsa9E/kzWqoMurYMTPbhqCHbER5Y8wIDAQABAoIBAAR/cBrGIwsEypvp | ||
l9VmHSQFIBlZrr/IguwqDFqaOGjRX8RMxTVieQ1Gr44Egkgv5r0wsnlziAPtM1Cb | ||
glR+76JkLys4WAZqZUlFi3VAmA4GWAGCFKWfic5kijVYsMy8cXSaISSoozdMUxCQ | ||
QR6M+1WEP+GkXxnx16TXsa7s0T9NExaYXOvMwijOztrN4s3qbSeDJeoXC7y2G3XK | ||
4ZUCSt42QDyMdeDHGI53mJDGDWDX52si+Tfs+J27do/XQfVQF2cl5R8L2jS3mOJ0 | ||
U8pDoB/HlZOEVxbYvgzE6c9gAFdMB9V90XCHFrHaOW027bLH0a8n4BuLZhWWHsSv | ||
aSHXRdECgYEA60kazg7hflRrvf4B4M4+j/Kqs0CKFucwF5bTEblnAylSSV8IUIp3 | ||
CCKev67VmB6vGqdfTe2jMPKlksVVjCz6BWL5uLiqdzT/v9Ok9HuV3SwwvcR7bNSq | ||
PAfrZ1Gzbz9KPH80ylkdHKy0L3AyB3nK2t0lB9Z8QBerYi/TZ7ZsR90CgYEAyTUJ | ||
6j9iFfSPg8U6LW+e3z1bRIi94TwNYvgWoObzWtyqPJVm7xgSOaMjbSnHzr5N+WfI | ||
1Rn0yLs2XXH0Ix1Zn7focgBM799yZl4LLCCxBp+GcvKV8F0fJA7GCw4861s6/fbP | ||
clQ89eD8pLolv0j+aVuK60nOQPfpeTza2Kdl/w8CgYA/sxAVv4OfHx34Vx+NDGl1 | ||
sV4zn4KDRt4HVOcaAlb4TSShBqCKpaIqSq0t+hiL0arYjX3I7FBlPRxEizZo9/hM | ||
owo2z5AfK/MdrSAYrKjbM06S4fIEeeMI06AQ3da1hK4FiO7y5YNzMvKpcTeqPHgG | ||
Hx8aayBCfeYBdC9JAeN45QKBgAj+DthiRs72ZCeee/Al6fLOOjMA7YOQfISs084T | ||
JFMuQ4l7n+MVr1LWILIzSNPLm46G/enQRClofJCGlEOxfxztSj02GDosQV+j2ln5 | ||
iA/kt0yR3POmJcslweIim8RlCmjpS/IvI55VlNUD4MYAzCYHSlkjrk0nB0880gcW | ||
zC8vAoGBAM3ChgcR0wG3+AqaWH9S+gw9ivLua4vrIYvWpVWsDgECHGAP8BXsKw7/ | ||
MOqIbzy23JRpqEQgMurlq9vFPHmp9ijvYJd0CsdGDQK3W6rZem8ZehVgegi0NLsG | ||
jIA5SdqiekQfDd+y0uySyDrwih32cYPB7xjYe3btBDRmPn1pbfDr | ||
-----END RSA PRIVATE KEY----- |
Binary file not shown.
9 changes: 9 additions & 0 deletions
9
protocolli/trasparente/testsuite/karate/jwks/testJWKrsapubkey.pem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuO0lSzNdA4G084FnllC1 | ||
gIZIWPBG5oGPC2XnsWWpw0Hw2dzo5e5nYzXGS9CChVRN6CPrybeksNuVAg8/RzCF | ||
1ZJmDCCkQeocNmrB0HhXJVLgLU3Bo4XZw/2G4zxo8RpemhyL2b3PzxplpKsmrIDI | ||
1TaCEgcvlsvmF6muMTmF9hnboGyXkapbrvVrxzU/WqZb580FzAFGyzSDNvUpIhl2 | ||
1k6An21jzwTQUS+M8hbXbbyO7SwMXlltbP0R1KYozBnxbfZyLlzIfw3ekuLqvjsR | ||
T68Ohej9WE3bCBKLJ2Bon7gpCgk0YaHlvGm6Dsa9E/kzWqoMurYMTPbhqCHbER5Y | ||
8wIDAQAB | ||
-----END PUBLIC KEY----- |
Binary file modified
BIN
+9.23 KB
(100%)
protocolli/trasparente/testsuite/karate/src/configurazioni-govway/trasparenteTestBundle.zip
Binary file not shown.
94 changes: 94 additions & 0 deletions
94
...pcoop2/core/protocolli/trasparente/testsuite/token/negoziazione/NegoziazioneJWKsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* GovWay - A customizable API Gateway | ||
* https://govway.org | ||
* | ||
* Copyright (c) 2005-2022 Link.it srl (https://link.it). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3, as published by | ||
* the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
package org.openspcoop2.core.protocolli.trasparente.testsuite.token.negoziazione; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import org.junit.Test; | ||
import org.openspcoop2.core.protocolli.trasparente.testsuite.Bodies; | ||
import org.openspcoop2.core.protocolli.trasparente.testsuite.ConfigLoader; | ||
import org.openspcoop2.utils.transport.http.HttpConstants; | ||
import org.openspcoop2.utils.transport.http.HttpRequest; | ||
import org.openspcoop2.utils.transport.http.HttpRequestMethod; | ||
import org.openspcoop2.utils.transport.http.HttpResponse; | ||
import org.openspcoop2.utils.transport.http.HttpUtilities; | ||
import org.slf4j.Logger; | ||
|
||
/** | ||
* NegoziazioneJWKsTest | ||
* | ||
* @author Francesco Scarlato ([email protected]) | ||
* @author $Author$ | ||
* @version $Rev$, $Date$ | ||
*/ | ||
public class NegoziazioneJWKsTest extends ConfigLoader { | ||
|
||
|
||
@Test | ||
public void jwk() throws Exception { | ||
|
||
_test(logCore, "test"); | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
protected static HttpResponse _test(Logger logCore, String operazione) throws Exception { | ||
|
||
String contentType = HttpConstants.CONTENT_TYPE_JSON; | ||
byte[]content = Bodies.getJson(Bodies.SMALL_SIZE).getBytes(); | ||
|
||
String url = System.getProperty("govway_base_path") + "/out/SoggettoInternoTestFruitore/SoggettoInternoTest/TestTramiteJWKs/v1/"+operazione; | ||
|
||
HttpRequest request = new HttpRequest(); | ||
|
||
request.setReadTimeout(20000); | ||
request.setMethod(HttpRequestMethod.POST); | ||
request.setContentType(contentType); | ||
request.setContent(content); | ||
request.setUrl(url); | ||
|
||
HttpResponse response = null; | ||
try { | ||
//System.out.println("INVOKE ["+request.getUrl()+"]"); | ||
response = HttpUtilities.httpInvoke(request); | ||
}catch(Throwable t) { | ||
throw t; | ||
} | ||
|
||
String idTransazione = response.getHeaderFirstValue("GovWay-Transaction-ID"); | ||
assertNotNull(idTransazione); | ||
|
||
verifyOk(response, 200, contentType); // è un flusso fruitore -> erogatore dove nell'erogatore viene verificato il token, è sufficiente il 200 | ||
|
||
return response; | ||
|
||
} | ||
|
||
public static void verifyOk(HttpResponse response, int code, String expectedContentType) { | ||
|
||
assertEquals(code, response.getResultHTTPOperation()); | ||
assertEquals(expectedContentType, response.getContentType()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.