@@ -43,6 +43,7 @@ import java.security.cert.X509Certificate
4343
4444
4545const  val  START_VPN_REQUEST  =  123 
46+ const  val  START_VPN_REQUEST_NO_CERT  =  124 
4647const  val  INSTALL_CERT_REQUEST  =  456 
4748const  val  SCAN_REQUEST  =  789 
4849const  val  PICK_APPS_REQUEST  =  499 
@@ -362,7 +363,11 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
362363                        }
363364                    }
364365                    .setNegativeButton(" Continue without certificate"  ) { _, _ -> 
365-                         onActivityResult(INSTALL_CERT_REQUEST , RESULT_OK , null )
366+                         if  (vpnNotConfigured) {
367+                             startActivityForResult(vpnIntent, START_VPN_REQUEST_NO_CERT )
368+                         } else  {
369+                             onActivityResult(START_VPN_REQUEST_NO_CERT , RESULT_OK , null )
370+                         }
366371                    }
367372                    .show()
368373            }
@@ -500,6 +505,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
500505        Log .i(TAG , " onActivityResult: "   +  (
501506                when  (requestCode) {
502507                    START_VPN_REQUEST  ->  " start-vpn" 
508+                     START_VPN_REQUEST_NO_CERT  ->  " start-vpn-nocrt" 
503509                    INSTALL_CERT_REQUEST  ->  " install-cert" 
504510                    SCAN_REQUEST  ->  " scan-request" 
505511                    PICK_APPS_REQUEST  ->  " pick-apps" 
@@ -516,6 +522,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
516522            if  (requestCode ==  START_VPN_REQUEST  &&  currentProxyConfig !=  null ) {
517523                Log .i(TAG , " Installing cert..."  )
518524                ensureCertificateTrusted(currentProxyConfig!! )
525+             } else  if  (requestCode ==  START_VPN_REQUEST_NO_CERT  &&  currentProxyConfig !=  null ) {
526+                 Log .i(TAG , " Ignore cert..."  )
527+                 onActivityResult(INSTALL_CERT_REQUEST , RESULT_OK , null )
519528            } else  if  (requestCode ==  INSTALL_CERT_REQUEST ) {
520529                Log .i(TAG  ," Cert installed, checking notification perms..."  )
521530                ensureNotificationsEnabled()
0 commit comments