Skip to content

Conversation

@runeflobakk
Copy link
Member

More informational (and a bit less dramatic) message if the client refuses to trust the TLS server certificate.

E.g. if attempting to use a Posten signering web site URL in place of an API URL, the exception now looks like:

no.digipost.signature.client.core.exceptions.HttpIOException:
Error executing POST https://difitest.signering.posten.no/, because SSLException 
'Untrusted server certificate, according to OrganizationNumberValidation trusting organization number '984661185'.
Actual certificate from server response: CN=difitest.signering.posten.no
(serial number 266807810224456931373439957111026753236316, expires 2024-01-08T12:27:38+01:00[Europe/Oslo]),
issued by CN=R3, O=Let's Encrypt, C=US.
This normally indicates either a misconfiguration of this client library, or a mixup of URLs used to communicate with the API.
Make sure the request URL is correct, is actually for the API, and it aligns with the configured ServiceEnvironment.
It should e.g. not be a URL that is to be accessed by a user from a web browser.'
	at no.digipost.signature.client.core.internal.ClientHelper.requestNewRedirectUrl(ClientHelper.java:124)
	at no.digipost.signature.client.direct.DirectClient.requestNewRedirectUrl(DirectClient.java:54)
        ...

Notably, this removes a mention of a possible man-in-the-middle attack, and also contains some more hints on how to resolve the error.

This PR will solve and close #199

Includes some more information on what to check (request URL for API, certificate from
server, align with configured ServiceEnvionment) when a server
certificate is evaluated as untrusted when intending to use the API.

Also removes the overly dramatic reference to a possible
"man-in-the-middle attack".

Fixes #199
Copy link
Contributor

@simenstoa simenstoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@runeflobakk runeflobakk merged commit a9c5800 into main Oct 12, 2023
@runeflobakk runeflobakk deleted the less-drama-more-information branch October 12, 2023 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide better error message when user submits wrong signer url while requesting new redirect url

2 participants