Custom tls chain impl to fix callback issue and avoid copying #1246
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces a custom x509 chain impl. This allows us to preserve the native handle during the validation process which means that we don't need to recreate a native x509 chain during validation.
The original motivation however is quite distinct from that and sparked by https://fogbugz.unity3d.com/f/cases/1191987/ (for which this is a fix):
Depending on the used overload of MobileTlsContext.ValidateCertificate, the user does not receive any certificate in callbacks like
ServicePointManager.ServerCertificateValidationCallback
. Essentially the implementation fails to pass through the certificate if a X509CertificateCollection is provided, but works fine if a X509Chain is passed in (which is why this PR implements a X509ChainImpl)The AppleTls implementation (on which the UnityTls backend is based) has the same issue. See here mono#10198
I added a regression test on https://github.cds.internal.unity3d.com/unity/unity/tree/platform/foundation/tls/regression-test-1191987 which passes with Mono built from this branch but not before
(Ideally we merge this alongside the next mono update in trunk cc: @joncham )