summaryrefslogtreecommitdiff
path: root/src/de/blinkt
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-12-23 01:07:51 +0100
committerArne Schwabe <arne@rfc2549.org>2012-12-23 01:07:51 +0100
commit174a0c8a3807df22ebd5731e139c0f0bb511f85b (patch)
tree58b0e110fa5b5e0cf7c25e84e64fd8f860e2e5e9 /src/de/blinkt
parentfac7abcf6717bf1c188b04b9f42af3924cef8f33 (diff)
Fix importing of embedded PKCS12 files
Diffstat (limited to 'src/de/blinkt')
-rw-r--r--src/de/blinkt/openvpn/ConfigConverter.java50
-rw-r--r--src/de/blinkt/openvpn/ConfigParser.java7
2 files changed, 39 insertions, 18 deletions
diff --git a/src/de/blinkt/openvpn/ConfigConverter.java b/src/de/blinkt/openvpn/ConfigConverter.java
index 393384b8..c08b176d 100644
--- a/src/de/blinkt/openvpn/ConfigConverter.java
+++ b/src/de/blinkt/openvpn/ConfigConverter.java
@@ -143,23 +143,22 @@ public class ConfigConverter extends ListActivity {
private Intent installPKCS12() {
if(!((CheckBox)findViewById(R.id.importpkcs12)).isChecked()) {
- embedPKCS12File();
+ setAuthTypeToEmbeddedPKCS12();
return null;
+
}
-
- File possiblepkcs12 = findFile(mResult.mPKCS12Filename);
- if(possiblepkcs12!=null) {
+ String pkcs12datastr = mResult.mPKCS12Filename;
+ if(pkcs12datastr!=null && pkcs12datastr.startsWith(VpnProfile.INLINE_TAG)) {
Intent inkeyintent = KeyChain.createInstallIntent();
- byte[] pkcs12data;
- try {
- pkcs12data = readBytesFromFile(possiblepkcs12);
- } catch (IOException e) {
- return null;
- }
+
+ pkcs12datastr= pkcs12datastr.substring(VpnProfile.INLINE_TAG.length());
+
+
+ byte[] pkcs12data = Base64.decode(pkcs12datastr, Base64.DEFAULT);
+
inkeyintent.putExtra(KeyChain.EXTRA_PKCS12,pkcs12data );
- mAliasName = possiblepkcs12.getName().replace(".p12", "");
if(mAliasName.equals(""))
mAliasName=null;
@@ -174,8 +173,7 @@ public class ConfigConverter extends ListActivity {
- private void embedPKCS12File() {
- mResult.mPKCS12Filename = embedFile(mResult.mPKCS12Filename,true);
+ private void setAuthTypeToEmbeddedPKCS12() {
if(mResult.mPKCS12Filename!=null && mResult.mPKCS12Filename.startsWith(VpnProfile.INLINE_TAG)) {
if(mResult.mAuthenticationType==VpnProfile.TYPE_USERPASS_KEYSTORE)
mResult.mAuthenticationType=VpnProfile.TYPE_USERPASS_PKCS12;
@@ -234,7 +232,18 @@ public class ConfigConverter extends ListActivity {
}
- private File findFile(String filename)
+ private File findFile(String filename) {
+ File foundfile =findFileRaw(filename);
+
+ if (foundfile==null && filename!=null && !filename.equals(""))
+ log(R.string.import_could_not_open,filename);
+
+ return foundfile;
+ }
+
+
+
+ private File findFileRaw(String filename)
{
if(filename == null || filename.equals(""))
return null;
@@ -274,7 +283,6 @@ public class ConfigConverter extends ListActivity {
}
}
- log(R.string.import_could_not_open,filename);
return null;
}
@@ -324,10 +332,22 @@ public class ConfigConverter extends ListActivity {
// This where I would like to have a c++ style
// void embedFile(std::string & option)
+ if (mResult.mPKCS12Filename!=null) {
+ File pkcs12file = findFileRaw(mResult.mPKCS12Filename);
+ if(pkcs12file!=null) {
+ mAliasName = pkcs12file.getName().replace(".p12", "");
+ } else {
+ mAliasName = "Imported PKCS12";
+ }
+ }
+
+
mResult.mCaFilename = embedFile(mResult.mCaFilename);
mResult.mClientCertFilename = embedFile(mResult.mClientCertFilename);
mResult.mClientKeyFilename = embedFile(mResult.mClientKeyFilename);
mResult.mTLSAuthFilename = embedFile(mResult.mTLSAuthFilename);
+ mResult.mPKCS12Filename = embedFile(mResult.mPKCS12Filename,true);
+
if(mResult.mUsername != null && !mResult.mUsername.equals("")){
String data =embedFile(mResult.mUsername);
diff --git a/src/de/blinkt/openvpn/ConfigParser.java b/src/de/blinkt/openvpn/ConfigParser.java
index 7d93a94e..f2814f7e 100644
--- a/src/de/blinkt/openvpn/ConfigParser.java
+++ b/src/de/blinkt/openvpn/ConfigParser.java
@@ -235,8 +235,9 @@ public class ConfigParser {
"status",
"suppress-timestamps",
"tmp-dir",
+ "tun-ipv6",
"topology",
- "win-sys"
+ "win-sys",
};
@@ -451,9 +452,9 @@ public class ConfigParser {
if(connectretrymax!=null)
np.mConnectRetryMax =connectretrymax.get(1);
- Vector<Vector<String>> remotetls = getAllOption("remote-tls", 1, 1);
+ Vector<Vector<String>> remotetls = getAllOption("remote-cert-tls", 1, 1);
if(remotetls!=null)
- if(remotetls.get(1).equals("server"))
+ if(remotetls.get(0).get(1).equals("server"))
np.mExpectTLSCert=true;
else
options.put("remotetls",remotetls);