@@ -53,6 +53,25 @@ int RedisClient::ConnectionConfig::connectionTimeout() const
5353 return param<int >(" timeout_connect" );
5454}
5555
56+ QList<QSslCertificate> RedisClient::ConnectionConfig::sslCaCertificates () const
57+ {
58+ QString path = param<QString>(" ssl_ca_cert_path" );
59+ if (!path.isEmpty () && QFile::exists (path))
60+ return QSslCertificate::fromPath (path);
61+
62+ return QList<QSslCertificate>();
63+ }
64+
65+ QString RedisClient::ConnectionConfig::sslPrivateKeyPath () const
66+ {
67+ return getValidPathFromParameter (" ssl_private_key_path" );
68+ }
69+
70+ QString RedisClient::ConnectionConfig::sslLocalCertPath () const
71+ {
72+ return getValidPathFromParameter (" ssl_local_cert_path" );
73+ }
74+
5675bool RedisClient::ConnectionConfig::isSshPasswordUsed ()
5776{
5877 return !param<QString>(" ssh_password" ).isEmpty ();
@@ -93,6 +112,11 @@ bool RedisClient::ConnectionConfig::useAuth() const
93112 return !param<QString>(" auth" ).isEmpty ();
94113}
95114
115+ bool RedisClient::ConnectionConfig::useSsl () const
116+ {
117+ return !param<QString>(" ssl_ca_cert_path" ).isEmpty ();
118+ }
119+
96120bool RedisClient::ConnectionConfig::isValid () const
97121{
98122 return isNull () == false
@@ -112,11 +136,7 @@ QWeakPointer<RedisClient::Connection> RedisClient::ConnectionConfig::getOwner()
112136
113137QString RedisClient::ConnectionConfig::getSshPrivateKey ()
114138{
115- QString path = param<QString>(" ssh_private_key_path" );
116- if (path.isEmpty () || !QFile::exists (path))
117- return QString ();
118-
119- return path;
139+ return getValidPathFromParameter (" ssh_private_key_path" );
120140}
121141
122142QString RedisClient::ConnectionConfig::keysPattern () const
@@ -145,6 +165,9 @@ RedisClient::ConnectionConfig RedisClient::ConnectionConfig::fromXml(QDomNode &
145165 valueMapping.insert (" sshPassword" , " ssh_password" );
146166 valueMapping.insert (" sshPort" , " ssh_port" );
147167 valueMapping.insert (" sshPrivateKey" , " ssh_private_key_path" );
168+ valueMapping.insert (" ssl_ca_cert_path" , " " );
169+ valueMapping.insert (" ssl_private_key_path" , " " );
170+ valueMapping.insert (" ssl_local_cert_path" , " " );
148171 valueMapping.insert (" namespaceSeparator" , " namespace_separator" );
149172 valueMapping.insert (" connectionTimeout" , " timeout_connect" );
150173 valueMapping.insert (" executeTimeout" , " timeout_execute" );
@@ -212,6 +235,12 @@ QDomElement RedisClient::ConnectionConfig::toXml()
212235 saveXmlAttribute (dom, xml, " sshPrivateKey" , param<QString>(" ssh_private_key_path" ));
213236 }
214237
238+ if (useSsl ()) {
239+ saveXmlAttribute (dom, xml, " ssl_ca_cert_path" , param<QString>(" ssl_ca_cert_path" ));
240+ saveXmlAttribute (dom, xml, " ssl_private_key_path" , param<QString>(" ssl_private_key_path" ));
241+ saveXmlAttribute (dom, xml, " ssl_local_cert_path" , param<QString>(" ssl_local_cert_path" ));
242+ }
243+
215244 return xml;
216245}
217246
@@ -221,3 +250,12 @@ void RedisClient::ConnectionConfig::saveXmlAttribute(QDomDocument & document, QD
221250 attr.setValue (value);
222251 root.setAttributeNode (attr);
223252}
253+
254+ QString RedisClient::ConnectionConfig::getValidPathFromParameter (const QString &name) const
255+ {
256+ QString path = param<QString>(name);
257+ if (path.isEmpty () || !QFile::exists (path))
258+ return QString ();
259+
260+ return path;
261+ }
0 commit comments