if (IsServer) {
SetPrivateCertificate (nativeServerCertificate);
} else {
- ssl.SetServerName (TargetHost);
+ ssl.SetServerName (ServerName);
}
}
static Exception GetException (MonoBtlsSslError status)
{
- var error = MonoBtlsError.GetError ();
+ string file;
+ int line;
+ var error = MonoBtlsError.GetError (out file, out line);
+ if (error == null)
+ return new MonoBtlsException (status);
+
var text = MonoBtlsError.GetErrorString (error);
- return new MonoBtlsException ("{0} {1}", status, text);
+
+ string message;
+ if (file != null)
+ message = string.Format ("{0} {1}\n at {2}:{3}", status, text, file, line);
+ else
+ message = string.Format ("{0} {1}", status, text);
+ return new MonoBtlsException (message);
}
public override bool ProcessHandshake ()
if (!IsServer)
ctx.SetSelectCallback (SelectCallback);
- var host = TargetHost;
- if (!string.IsNullOrEmpty (host)) {
- var pos = TargetHost.IndexOf (':');
- if (pos > 0)
- host = host.Substring (0, pos);
- }
-
- ctx.SetVerifyParam (MonoBtlsProvider.GetVerifyParam (host, IsServer));
+ ctx.SetVerifyParam (MonoBtlsProvider.GetVerifyParam (ServerName, IsServer));
TlsProtocolCode minProtocol, maxProtocol;
GetProtocolVersions (out minProtocol, out maxProtocol);
var cipher = (CipherSuiteCode)ssl.GetCipher ();
var protocol = (TlsProtocolCode)ssl.GetVersion ();
+ var serverName = ssl.GetServerName ();
Debug ("GET CONNECTION INFO: {0:x}:{0} {1:x}:{1} {2}", cipher, protocol, (TlsProtocolCode)protocol);
connectionInfo = new MonoTlsConnectionInfo {
CipherSuiteCode = cipher,
- ProtocolVersion = GetProtocol (protocol)
+ ProtocolVersion = GetProtocol (protocol),
+ PeerDomainName = serverName
};
}
public override void Close ()
{
Debug ("Close!");
- ssl.Dispose ();
+
+ if (ssl != null) {
+ ssl.Dispose ();
+ ssl = null;
+ }
+ if (ctx != null) {
+ ctx.Dispose ();
+ ctx = null;
+ }
+ if (bio != null) {
+ bio.Dispose ();
+ bio = null;
+ }
+ if (errbio != null) {
+ errbio.Dispose ();
+ errbio = null;
+ }
}
void Dispose<T> (ref T disposable)