Commit c6f0b9df authored by Lamarque Souza's avatar Lamarque Souza
Browse files

Add support to import .ovpn files with syntax described in

http://openvpn-users.narkive.com/ZwzahkCv/embedding-key-cert-ca-into-client-config

BUG: 349282
FIXED-IN: 0.9.3.7
parent 4151c470
......@@ -398,6 +398,10 @@ NMVariantMapMap OpenVpnUiPlugin::importConnectionSettings(const QString &fileNam
}
if (key_value[0] == CA_TAG && key_value.count() > 1) {
key_value[1] = line.right(line.length() - line.indexOf(QRegExp("\\s"))); // Get whole string after key
if (key_value[1].trimmed() == QLatin1String("[inline]")) {
// No data or file to copy for now, it will be available later when we reach <ca> tag.
continue;
}
if (copyCertificates) {
const QString absoluteFilePath = tryToCopyToCertificatesDirectory(connectionName, unQuote(key_value[1], fileName));
dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CA), absoluteFilePath);
......@@ -408,6 +412,10 @@ NMVariantMapMap OpenVpnUiPlugin::importConnectionSettings(const QString &fileNam
}
if (key_value[0] == CERT_TAG && key_value.count() > 1) {
key_value[1] = line.right(line.length() - line.indexOf(QRegExp("\\s"))); // Get whole string after key
if (key_value[1].trimmed() == QLatin1String("[inline]")) {
// No data or file to copy for now, it will be available later when we reach <cert> tag.
continue;
}
if (copyCertificates) {
const QString absoluteFilePath = tryToCopyToCertificatesDirectory(connectionName, unQuote(key_value[1], fileName));
dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CERT), absoluteFilePath);
......@@ -418,6 +426,10 @@ NMVariantMapMap OpenVpnUiPlugin::importConnectionSettings(const QString &fileNam
}
if (key_value[0] == KEY_TAG && key_value.count() > 1) {
key_value[1] = line.right(line.length() - line.indexOf(QRegExp("\\s"))); // Get whole string after key
if (key_value[1].trimmed() == QLatin1String("[inline]")) {
// No data or file to copy for now, it will be available later when we reach <key> tag.
continue;
}
if (copyCertificates) {
const QString absoluteFilePath = tryToCopyToCertificatesDirectory(connectionName, unQuote(key_value[1], fileName));
dataMap.insert(QLatin1String(NM_OPENVPN_KEY_KEY), absoluteFilePath);
......@@ -444,12 +456,17 @@ NMVariantMapMap OpenVpnUiPlugin::importConnectionSettings(const QString &fileNam
}
if (key_value[0] == TLS_AUTH_TAG && key_value.count() >1) {
key_value[1] = line.right(line.length() - line.indexOf(QRegExp("\\s"))); // Get whole string after key
if (copyCertificates) {
const QString absoluteFilePath = tryToCopyToCertificatesDirectory(connectionName, unQuote(key_value[1], fileName));
dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TA), absoluteFilePath);
} else {
dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TA), unQuote(key_value[1], fileName));
// We will copy inline certificate later when we reach <tls-auth> tag.
if (key_value[1].trimmed() != QLatin1String("[inline]")) {
if (copyCertificates) {
const QString absoluteFilePath = tryToCopyToCertificatesDirectory(connectionName, unQuote(key_value[1], fileName));
dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TA), absoluteFilePath);
} else {
dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TA), unQuote(key_value[1], fileName));
}
}
if (key_value.count() > 2) {
key_value[2] = key_value[1];
if (!key_value[2].isEmpty() && (key_value[2].toLong() == 0 ||key_value[2].toLong() == 1))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment