schwabe / ics-openvpn

OpenVPN for Android
3.31k stars 1.2k forks source link

openvpn : Got unrecognized command>FATAL:ERROR: Cannot open TUN #1596

Closed deletexl closed 1 year ago

deletexl commented 1 year ago

To make issues more manageable, I would appreciate it if you fill out the following details as applicable:

General information

  1. Android Version 10-11-12
  2. Android Vendor/Custom ROM samsung / huawei
  3. Device Samsung a80 - Huawei mate lite
  4. Version of the app (version number/play store version/self-built)

Description of the issue

hello i want to establish a vpn connection there is an ovpn file i can successfully connect with openvpn connect on desktop and mobile. But when I run it with the help of the library, sometimes the connection is provided without any problems, and sometimes I see a result like the following. Any ideas?

Log (if applicable)

NOPROCESS
VPN_GENERATE_CONFIG
WAIT
AUTH
ASSIGN_IP
openvpn : Got unrecognized command>FATAL:ERROR: Cannot open TUN
openVPN : OpenVPN process exited
NOPROCESS
OpenVPN : Exiting
DISCONNECTED

Configuration file

client
proto udp
explicit-exit-notify
remote **.***.***.206 1194
dev tun
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
verify-x509-name server_Lwws41wyAmhsRiuI name
auth SHA256
auth-nocache
cipher AES-128-GCM
tls-client
tls-version-min 1.2
tls-cipher TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
ignore-unknown-option block-outside-dns
setenv opt block-outside-dns # Prevent Windows 10 DNS leak
verb 3
<ca>
-----BEGIN CERTIFICATE-----
MIIB1jCCAX.......
-----END CERTIFICATE-----
</ca>
<cert>
-----BEGIN CERTIFICATE-----
MIIB1zCCAX6gAwIBAgIQTm2RmsdAX4XIBnSEljNx+TAKBggqhkjOPQQDAjAeMRww
GgYDVQQDDB.....
-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN PRIVATE KEY-----
MIGHAgEAM.......
-----END PRIVATE KEY-----
</key>
<tls-crypt>
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
26ee41fe77e8b1e1fd61a8e0b1b983e1
......
-----END OpenVPN Static key V1-----
</tls-crypt>
schwabe commented 1 year ago

Please provide a full log.

Also please note that this is an application not a library and only reports for my actual app are valid here. I am frustrated and sick of supporting people stealing my source code and creating closed source apps from it and then having the audacity to then ask for help doing it.

deletexl commented 1 year ago

@schwabe Hello, I am developing my application with the help of C++ and JNI using a different IDE, not Android Studio. This is not a closed source application, I'm just writing an article on how to do this kind of thing using JNI. So I'm not sure how I can view the detailed logs. How can I do this? This is my code that creates VPN connection

` public native void vpnStatusChanged(String status);

public VPNWrapper(Activity ac, Context ctx) {
    this.tmpActivity = ac;
    this.tmpContext = ctx;

    vpnIntent = VpnService.prepare(tmpContext);

    LocalBroadcastManager.getInstance(ctx).registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String stage = intent.getStringExtra("state");
            vpnStatusChanged(stage);
        }
    }, new IntentFilter("connectionState"));
}

public void startVPN(String ovpn, Context context) {
    try {
        if(this.netCheck(context)) {
            this.checkPermissions();
            ConfigParser cf = new ConfigParser();
            cf.parseConfig(new StringReader(ovpn));
            this.vpnProfile = cf.convertProfile();
            vpnIntent = VpnService.prepare(context);
            if(vpnIntent != null) {
                this.tmpActivity.startActivityForResult(vpnIntent, 1);
            }
            if (vpnProfile.checkProfile(context) != de.blinkt.openvpn.R.string.no_error_found) {
                throw new RemoteException(this.tmpActivity.getString(vpnProfile.checkProfile(context)));
            }
            ProfileManager.setTemporaryProfile(context, vpnProfile);
            VPNLaunchHelper.startOpenVpn(vpnProfile, context);
        } else {
            Toast.makeText(context, "No internet connection ", Toast.LENGTH_LONG);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ConfigParser.ConfigParseError configParseError) {
        configParseError.printStackTrace();
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}

public void stopVPN() {
    try {
        OpenVPNThread.stop();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

`

schwabe commented 1 year ago

@deletexl I am skeptical. You also only provide details on how you trying to do on an absolute minimum, which typically people do that want to hide something. So you are writing an article but report bugs to my tracker without opening with that? And what article that tries to demonstrate that uses OpenVPN instead a simple toy VPN. This raises more questions than it answers.

deletexl commented 1 year ago

I don't understand what this means, but thank you anyway. I would solve the problem myself if you at least leave a comment for the codes. I'll post the solution here.

schwabe commented 1 year ago

@deletexl that means that I have been treated very badly by people in the past and you could not convince me that you are any better, sorry.

deletexl commented 1 year ago

@schwabe Ok, thank you, I'll update this if I get a result.