Better client compatibility (copy SAN and Subject)

These first patch upgrade the bouncy castle implementation so a nicer API can be used for passing multiple SANs.

The second patch copies the Subject and SAN (Subject Alternative Name) fields from the server certificate to support clients which check the names manually. To enable this to work, I had to change the order in which certificates and connections are established.

The third patch is useful for debugging.