Bug 38969 - [NEED-DOCUMENTATION] Passing intermediate CA certificates (SslClientStream and SslServerStream do not allow CA certificates to be specified)
Summary: [NEED-DOCUMENTATION] Passing intermediate CA certificates (SslClientStream an...
Alias: None
Product: Class Libraries
Classification: Mono
Component: Mono.Security ()
Version: 4.2.0 (C6)
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
Depends on:
Reported: 2016-02-20 23:32 UTC by Dr. John Wason
Modified: 2016-11-19 00:20 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 38969 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Dr. John Wason 2016-02-20 23:32:04 UTC
I am using certificates that are loaded at runtime for  Mono.Security.Protocol.Tls.SslClientStream and  Mono.Security.Protocol.Tls.SslServerStream.  While the certificates do work properly, it is not possible to specify intermediate CA certificates to be sent along with the end certificate. The intermediate certificates need to be installed in the system wide "CA" store.  In fact, if the "CA" store does not exist (/usr/share/.mono/certs/CA), an error is thrown on construction and the SslServerStream cannot be used. Accessing this store requires root permissions.  Because of this behavior it is necessary to have root permissions in order to use a certificate key pair with TLS which should not be necessary if the certificates and keys are provided in some other way. The SslClientStream and SslServerStream should be designed so it is possible to specify the intermediate certificates on construction of SslClientStream and SslServerStream and have them sent to the peer as part of the certificate chain during the handshake. For instance, there should be constructors with something similar to these parameters:

public SslClientStream(	Stream stream, string targetHost, X509Certificate clientCertificate, X509Certificate[] caCertificates)


public SslServerStream(	Stream stream, X509Certificate serverCertificate, bool clientCertificateRequired, bool ownsStream, X509Certificate[] caCertificates)

If the built in store /usr/share/.mono/certs/CA is non-existent it should be assumed to be empty instead of throwing an error.
Comment 1 Martin Baulig 2016-11-11 10:27:42 UTC
SslClientStream / SslServerStream has been obsoleted by the new TLS implementations (AppleTls and BTLS) and won't be updated anymore.

Also, the cert store is a mess and needs some serious love at some point.  This will hopefully happen for Cycle 10, but not for this upcoming Cycle 9.

                                     * * *

However, the good news is that I actually addressed this problem while working on the new AppleTLS and BTLS implementation and provided a way of providing intermediate certificates - though it isn't really documented very well.

You need to create a PKCS#12 file containing both your client / server certificate, its private key and all the intermediate certificates that you would like to send along.

Then create an X509Certificate2 from that PKCS#12 and pass it to SslStream / HttpWebRequest / HttpListener or where-ever else you would use the X509Certificate2 to pass a client / server certificate.

The implementation will "magically" remember the intermediate certificates contained in the PKCS#12 and send them along.
Comment 2 Dr. John Wason 2016-11-19 00:20:21 UTC
I was using the Mono SSL library because my application requires full access to the returned SSL certificate chain on the client side. For Windows, this is easily accomplished, however for Mono on Apple platforms it wasn't working when I last checked in the Spring. Will the new versions pass the full certificate chain to the client? If the Mono libraries are deprecated, what is the replacement?