Android 12 IKEv2 & RRAS

Crash The Great 6 Reputation points
2022-10-06T21:00:06.213+00:00

Hello, collegues!

Unfortunately, in Android 12+ (depend by manufacturer, but in my phone so) has been cut out support for all VPN protocols expect IKEv2/Ipsec.
What's may be better than use IKEv2/Ipsec MSCHAPv2 and have no trouble? But here is a requeried parameter "IPSec identifier", it can't be blank or null.
Anything I try to use for it not working (fqdn, $null, ip, ikev2, etc). For example, others hardware routers just ignore this parameter and connected succesfully, but not RRAS. Also there is no errors or warnings in logs.

Maybe anyone know how to setup this parameter in RRAS (or maybe in NPS)?

Thanks!

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,124 questions
Windows Server Infrastructure
Windows Server Infrastructure
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Infrastructure: A Microsoft solution area focused on providing organizations with a cloud solution that supports their real-world needs and meets evolving regulatory requirements.
513 questions
{count} vote

3 answers

Sort by: Most helpful
  1. Gary Nebbett 5,721 Reputation points
    2023-03-21T08:37:00.9+00:00

    Hello All,

    Which Key Exchange Method Transform ID (formerly known as DH (Diffie-Hellman) group) is your server configured to accept? By default, a Windows VPN server expects the "1024-bit MODP Group" (Group 2) but Android only offers the following:

    • 2048-bit MODP Group with 256-bit Prime Order Subgroup (Group24)
    • 384-bit random ECP group (ECP384)
    • 256-bit random ECP group (ECP256)
    • 2048-bit MODP Group (Group14)
    • 1536-bit MODP Group (Group5)

    Unless the VPN server has been configured to expect one of the above, the connection will fail.

    The Microsoft article https://learn.microsoft.com/en-us/windows/security/identity-protection/vpn/how-to-configure-diffie-hellman-protocol-over-ikev2-vpn-connections explains how to change the setting and Richard Hicks' article https://directaccess.richardhicks.com/2018/12/10/always-on-vpn-ikev2-security-configuration/ also discusses the topic.

    Both of the articles use PowerShell cmdlets to change the settings; unfortunately, there is not a simple PowerShell command to show the current settings. Richard Hicks suggests using the command Get-NetIPsecMainModeSA, but this only works when Main Mode security associations are present (i.e. when VPN clients are connected). In the quiescent state (no active Main Mode security associations) it may be necessary to examine the stored settings in the registry (see section 2.2.3.4.2.8 IKEv2 Custom Policy Configuration of [MS-RRASM]) or the active Windows Filtering Platform state on the VPN server (use "netsh wfp show state" to obtain the state and then search that for the IkeV2MmPolicy elements).

    Gary

    1 person found this answer helpful.

  2. Alisson Nunes 0 Reputation points
    2023-03-27T18:39:41.1433333+00:00

    I haven't found any way to bind ipsec identifier on windows server.

    The only way I could make it work was using an alternative VPN client: strongSwang. Available on play store

    https://play.google.com/store/apps/details?id=org.strongswan.android

    In it, the ipsec identifier field does not even exist, when choosing the option equivalent to IKEV2 MSCHAPV2,which is IKEV2 EAP (username/password).

    However, with it you need to select the root CA certificate, which can be imported through it.

    To import the root CA certificate, simply uncheck the option "CA CERTIFICATE select automatically", "click" on the area just below, click on the options button (3 dots), and choose import certificate. The certificate file MUST be a root CA certificate file (.cer in windows server case), which needs to be copied to a file via certrv (in AD CS server) or downloaded via http://ipofaadcsserver/certsrv.

    Also the VPN server needs one more different thing compared to L2TP/PPTP:

    1- As explained by our esteemed friend Gary, is mandatory the change of Key Exchange Method Transform ID for android compatible one as windows server default is not. One of the commands could be this:

    Set-VpnServerConfiguration -CustomPolicy -AuthenticationTransformConstants SHA256128 -CipherTransformConstants AES128 -DHGroup Group14 -EncryptionMethod AES128 -IntegrityCheckMethod SHA256 -PFSgroup PFS2048 -SALifeTimeSeconds 28800 -MMSALifeTimeSeconds 86400 -SADataSizeForRenegotiationKilobytes 1024000
    
    Restart-Service RemoteAccess -PassThru
    

    Beware, this command does not work for all versions of windows server. I tested it on 2019 and it worked, but in 2012 it didn't. In 2016 i dont know.

    And that's it.

    0 comments No comments

  3. Gary Nebbett 5,721 Reputation points
    2023-03-22T19:54:41.6066667+00:00

    Hello All,

    I am not sure that I am a "qualified" person to answer a question like "Do u know how i generate a correct cert for android O.S." - a good answer would need knowledge of how the Android VPN client is implemented.

    As I understand the situation, there are 3 types of IKEv2 authentication (quoting from IKEv2 RFC):

       In addition to authentication using public key signatures and shared
       secrets, IKE supports authentication using methods defined in RFC
       3748 [EAP].  
    
    1. public key signatures
    2. shared secrets
    3. EAP

    An Android 13 IKEv2/IPsec PSK (Pre-Shared Key = shared secret) connection is easy to define - it just requires a server name/address and the "secret". This option is not available when configuring a VPN client under Windows 11.

    User's image

    An Android 13 IKEv2/IPsec RSA connection possibly corresponds to the Windows 11 "Use machine certificates" (but could also be EAP-TLS - not tested/confirmed). This authentication method requires a private key and (optionally but preferred) corresponding certificate; the IKEv2 RFC says:

    Optionally, messages 3 and 4 MAY include a certificate, or certificate chain providing evidence that the key used to compute a digital signature belongs to the name in the ID payload.

    An Android 13 IKEv2/IPsec MSCHAPv2 connection corresponds to a Windows 11 "Use Extensible Authentication Protocol (EAP)" connection with a method of "Microsoft: Secured password (EAP-MSCHAP v2)". This method requires a root authority certificate of the issuer of the VPN server certificate.

    I wanted to use MSCHAPv2, but when I made .cer (DER encoded X.509) or .p7b (PKCS#7) files available containing the root authority certificate, I could not load them (they did not appear) in the Android "Other security settings>Install from device storage>VPN and app user certificate" list.

    I therefore created a PKCS#12 (.p12, .pfx) file that contained the root authority certificate and a plausible/usable private key and certificate for the client(s) (I used a generic name of "VPN Guest"). This file could be loaded via "Other security settings>Install from device storage>VPN and app user certificate".

    Hopefully the above explains why I said that: there are more items in my "IPsec CA certificate" file than I think necessary. With that file, I can connect with both "IKEv2/IPsec RSA" and "IKEv2/IPsec MSCHAPv2".

    The title of this thread is "Android 12 IKEv2 & RRAS" - I assume that readers of this topic are familiar with (and possibly manage) RRAS (Routing and Remote Access Service), NPS (Network Policy Server) and Windows Certificate Services. If that is not the case then please expand on which topics you are unfamiliar with.

    Gary

    1 person found this answer helpful.