Andre Paques
Sep 12, 2018
2:25 pm

How to create profile with GenericVpnPolicy no error Json

Dear friends,
I have two questions:
1: Through the GenericVpnPolicy Class, can I create a Vpn without the need for a screen lock? This information not content in the documentation of the Api.

2: The following exception: "Error VPN error 103: Invalid JSON format" is constant for me in all attempts to create a VPN with class GenericVpnPolicy, I have already taken several examples Json to build the profile and always generate the error.
Here's the data I've been passing the string in: createVpnProfile (String profileInfo).
String VPN_PROFILE_JSON_FORMAT = "" +
            "\" KNOX_VPN_PARAMETERS \ ":" +
            "{" +
                "\" profile_attribute \ ":" +
                    "{" +
                        "\" profileName \ ": \" ExampleGeneric \ "," +
                        "\" vpn_type \ ": \" ipsec \ "," +
                        "\" vpn_route_type \ ": 0" + "
                    "}," +
                "\" vendor \ ":" +
                    "{" +
                        "\" basic \ ":" +
                            "{" +
                                "\" host \ ": \" x.x.x.x \ "," +
                                "\" username \ ": \" vpn \ "," +
                                "\" password \ ": \" vpn \ "," +
                                "\" authentication_type \ ": 2" +
                            "}," +
                        "\" ipsec_xauth_psk \ ":" +
                            "{" +
                                "\" identifier \ ": \" ***** \ "" +
                                "\" pre_shared_key \ ": \"*****x1234\ "" +
                            "}" +
                    "}," +
            "}";

 

How to can i to manager this problem?

Similar topics

No similar topics found.
Jenna S.Samsung SEAP Moderator
Sep 12, 2018
6:40 pm

Hello Andre

Please look at this line:

                        "\" vpn_route_type \ ": 0" + "

I believe that the last quotation mark is what is causing the issue. Please try looking into the format there, and let me know if the issue still persists.

Best regards,

Jenna

Andre Paques
Sep 12, 2018
7:39 pm

Hi Jenna,

Thank you for responding quickly.

I've already tried the suggested fix, tried the string contained in the vpn example app on the sdk page and without success, look how I write the string in full:
String VPN_PROFILE_INFO_JSON_FORMAT = "{\" KNOX_VPN_PARAMETERS \ ": {\" profile_attribute \ ": {\" profileName \ ": \" Autotrac \ ", \" vpn_type \ ": \" ipsec \ ", \" vpn_route_type \ ": 1 } "\" "\" \ "\" \ "\" \ "\" \ test \ ", \" authentication_type \ ": 2}, \" ipsec_xauth_psk \ ": {\" identifier \ ": \" Autotrac \ ", \" pre_shared_key \ ": \" bdca1234 \ "}}}}";
One question, do you think I'm filling in the fields correctly, and am I just wrong in the format?

Andre Paques
Sep 12, 2018
8:12 pm

Correcting the previous message, follows the mode with which I tried:

String VPN_PROFILE_INFO_JSON_FORMAT = "{'KNOX_VPN_PARAMETERS': {'profile_attribute': {'profileName': 'Autotrac', 'vpn_type': 'ipsec', 'vpn_route_type': 1}, 'vendor':{'basic': {'host':'10.239.239.161', 'username':'test', 'password':'test', 'authentication_type':2}, 'ipsec_xauth_psk':{'identifier':'Autotrac', 'pre_shared_key':'bdca1234'}}}} ";

Jay H.Samsung SEAP Moderator
Sep 12, 2018
11:15 pm

Hi Andre,

Have you tried manually setting up the VPN with these values?

We have a sample app on SEAP for VPN configuration. Following is the JSON from that, which can successfully create a VPN profile:

{
  "KNOX_VPN_PARAMETERS":{
    "profile_attribute": {
        "profileName":"genericvpn", 
        "host":"1.1.1.1", 
        "isUserAuthEnabled":true,
        "vpn_type":"ipsec", 
        "vpn_route_type":1 
      }, 
      "ipsec": { 
        "basic": { 
          "username":"test", 
          "password":"test", 
          "authentication_type":1, 
          "psk":"example", 
          "ikeVersion":2, 
          "dhGroup":2, 
          "p1Mode":2, 
          "identity_type":0, 
          "identity": "test@test.com", 
          "splitTunnelType":0, 
          "forwardRoutes":[ ] 
      }, 
      "advanced": { 
        "mobikeEnabled":false, 
        "pfs":false, 
        "deadPeerDetect":false, 
        "dhGroup":2, 
        "p1Mode":2 
      }, 
      "algorithms": { } 
      }, 
      "ssl": { 
        "basic": { }, 
        "algorithms":{ } 
      }, 
      "knox": { }, 
      "vendor":{ } 
  } 
}

 

Can you try following this format for your JSON? Note that those values are configured for the Strongswan server. Your VPN server might not require all the values, in which case you can leave the keys blank.

Regards,
Jay