I want to add some light on this SSL handshake and communication over HTTPS.
If you're facing this issue "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel" it means one of the below condition not met:
- Certificate signatures are valid
- Certificate chain ends at a trusted root
- Chain has valid basic constraints
- Successful revocation check / not revoked. CRL endpoint is accessible.
or due to below constraint:
- Chain has name constraint policies.
- Chain has certificate policies
- Chain has extended key usages
- Chain has SubjectKeyIdentifier / AuthorityKeyIdentifier match
If you're using Azure web app with domain {webappname}.azurewebsites.net and using internal private certificate then there is no workaround of this issue other than below three options as this is unsupported scenario:
I) App service environment
I))need to bypass the SSL validation
III) Use well known Certificate Authority certificate to make it work.
Why unsupported scenario:
you cannot install new certificate authority on web app level because you're using shareable resources and not dedicated.
Even if you install the certificate to azure using app configuration "WEBSITES_LOAD_CERTIFICATES" it don't allows to install the certificate inside certificate store.
You can learn the failure through network trace and it should failed at "Authentication and Pre-master secret" stage which is after server hello.
I hope this information helps.