Skip to content

Commit e4af215

Browse files
committed
Refactor SslOption to make it cleaner to use and more contained
* Add an Enabled boolean property * Rename refactoring SslFooBar are now FooBar and m_sslFoo are now m_foo * Rename Cert to CertPath, so its intent is clearer * Rename CertCollection to Certs. We do not need to expose its implementation * More whitespace, more room to breath * Change the core Constructor to also take a boolean enabled value * Add an overloaded constructor with No parameters
1 parent ad0ab76 commit e4af215

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

src/client/api/SslOption.cs

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,47 @@ namespace RabbitMQ.Client
6767
public class SslOption
6868
{
6969

70-
private SslProtocols m_sslVersion = SslProtocols.Ssl3;
70+
private bool m_enabled;
71+
72+
///<summary>Flag specifying if Ssl should indeed be
73+
///used</summary>
74+
public bool Enabled
75+
{
76+
get { return m_enabled; }
77+
set { m_enabled = value; }
78+
}
79+
80+
81+
private SslProtocols m_version = SslProtocols.Ssl3;
7182

7283
///<summary>Retrieve or set the path to client certificate.
7384
///</summary>
74-
public SslProtocols SslVersion
85+
public SslProtocols Version
7586
{
76-
get { return m_sslVersion; }
77-
set { m_sslVersion=value; }
87+
get { return m_version; }
88+
set { m_version = value; }
7889
}
7990

80-
private string m_cert;
91+
private string m_certPath;
8192

8293
///<summary>Retrieve or set the path to client certificate.
8394
///</summary>
84-
public string Cert
95+
public string CertPath
8596
{
86-
get { return m_cert; }
87-
set { m_cert=value; }
97+
get { return m_certPath; }
98+
set { m_certPath = value; }
8899
}
89100

90101
///<summary>Convenience read-only property to retrieve an X509CertificateCollection
91102
///containing the client certificate</summary>
92-
public X509CertificateCollection CertCollection
103+
public X509CertificateCollection Certs
93104
{
94105
get {
95-
if(m_cert == "") {
106+
if(m_certPath == "") {
96107
return null;
97108
} else {
98109
X509CertificateCollection c = new X509CertificateCollection();
99-
c.Add(X509Certificate.CreateFromCertFile(m_cert));
110+
c.Add(X509Certificate.CreateFromCertFile(m_certPath));
100111
return c;
101112
}
102113
}
@@ -109,24 +120,31 @@ public X509CertificateCollection CertCollection
109120
public string ServerName
110121
{
111122
get { return m_serverName; }
112-
set { m_serverName=value; }
123+
set { m_serverName = value; }
113124
}
114125

115126

127+
128+
///<summary>Construct an SslOption specifying both the server cannonical name
129+
///and the client's certificate path.
130+
///</summary>
131+
public SslOption(string serverName, string certPath, bool enabled)
132+
{
133+
m_serverName= serverName;
134+
m_certPath = certPath;
135+
m_enabled = enabled;
136+
}
137+
116138
///<summary>Construct an SslOption with just the server cannonical name.
117139
///The Certificate path is set to an empty string
118140
///</summary>
119-
public SslOption(string serverName): this(serverName, "")
141+
public SslOption(string serverName): this(serverName, "", false)
120142
{
121143
}
122144

123-
///<summary>Construct an SslOption specifying both the server cannonical name
124-
///and the client's certificate path.
125-
///</summary>
126-
public SslOption(string serverName, string cert)
145+
///<summary>Construct an SslOption with no parameters set</summary>
146+
public SslOption(): this("", "", false)
127147
{
128-
m_serverName= serverName;
129-
m_cert = cert;
130148
}
131149

132150
}

0 commit comments

Comments
 (0)