-
Notifications
You must be signed in to change notification settings - Fork 3k
Documentation of TLSSocket behavior on AUTH_FAILURE #9392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation of TLSSocket behavior on AUTH_FAILURE #9392
Conversation
Surely this is nothing to do with "AUTH_FAILURE"? It's a general restriction that the socket can only be used for one connection (attempt). That limitation is not that unusual for connection-type sockets in general, but may be worth noting here. (POSIX says: "If connect() fails, the state of the socket is unspecified. Conforming applications should close the file descriptor and create a new socket before attempting to reconnect.") |
Note: Travis failure is fixed on master (#9391) , if you can rebase to resolve the error |
bd07ade
to
ade5624
Compare
@0xc0170 , thanks, I rebased. |
features/netsocket/TLSSocket.h
Outdated
@@ -75,6 +75,9 @@ class TLSSocket : public TLSSocketWrapper { | |||
* Initiates a connection to a remote server specified by either | |||
* a domain name or an IP address and a port. | |||
* | |||
* @note: In case connect() returns an error, the state of the socket is | |||
* unspecified. A new socket should be created before reconnecting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unspecified
is not quite accurate.
See the documentation for mbedtls_ssl_handshake()
https://tls.mbed.org/api/ssl_8h.html#a4a37e497cd08c896870a42b1b618186e
We should reflect that in our documentation. So if this function returns failures other than what we specify, user should stop using the TLS context and free it. We don't support the mbedtls_ssl_session_reset()
but maybe we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be hard to reflect, but basically we could try the connect()
as long as it is the TCP session that fails the connection.
Basically, if SSL handshake fails, we return NSAPI_ERROR_AUTH_FAILURE
and after that, the socket cannot be used anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, if SSL handshake fails, we return NSAPI_ERROR_AUTH_FAILURE
I noticed we sometimes return PARAMETER_ERROR instead, but I saw no reason to do that and I modified the return value. Please take a look and if you agree with that change, I will amend the test's expectations (the tests documentation just says "must return an error", without specifying the exact error code, so that's fine).
If we always return AUTH_ERROR on ssl-related errors we can safaely tell the users that if they see this error, then they must get a new socket before retrying (which means they don't have to do that if they just want to retry the TCP connection).
Is that ok?
Do we actually need to reflect this We seem to allow |
ade5624
to
9bb47d6
Compare
9bb47d6
to
f4caf44
Compare
@michalpasztamobica All reviews addressed (we can see a new commit here) |
I think they are addressed, although I would prefer to see an explicit OK from @SeppoTakalo regarding the error code returns ;-) |
@0xc0170 , Travis passed and I think that the builds which were failing so far should now pass (as they don't really compile anything any more). Could you trigger the CI, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
Ready for CI, please rebase first to resolve conflicts (documentation update was merged recently) |
f4caf44
to
dbd00f5
Compare
Rebased and conflicts resolved. |
CI started |
Test run: FAILEDSummary: 1 of 1 test jobs failed Failed test jobs:
|
dbd00f5
to
a4ba6aa
Compare
Sorry, I checked Icetea tests and greentea tests, but forgot about the unit tests - latest push fixes the expected error return values. |
CI restarted |
Test run: FAILEDSummary: 1 of 1 test jobs failed Failed test jobs:
|
a4ba6aa
to
2cda5d2
Compare
Now the CI pointed out that I should also modify the DTLSSocketWrapper tests. I hope nothing more will come up... |
CI restarted |
I doubt my changes are causing the dynamic-memory-usage failure as I can see the same is happening in @VeijoPesonen 's Pull Request... |
Yes, test team is investigating. |
Test run: FAILEDSummary: 2 of 11 test jobs failed Failed test jobs:
|
I can see that 4 out of 5 failing greentea tests are not even related to ipcore.
@0xc0170 , is this something I should worry about? |
CI restarted |
I can't seem to patch this with either git am or git cherry-pick so I am bumping it to 5.12 |
5.12 is fine |
Description
It is not possible to store TLS certificate after opening a TLSSocket, due to mbedTLS limitation. We update the documentation to warn users and explain the reason.
(Internal JIRA with the full discussion is ONME-4121)
Pull request type
Reviewers
@SeppoTakalo
@VeijoPesonen