Keys to success (pun intended).
- Need two certs on Iphone: the client cert and the base cert (.ca) but now done separately.
- Require subj alter name format for server and client certs - DNS:actual name (and not common name)
- also max days allowed is 800 days
Path to Success.
MIKROTIK
(1) Create Base .ca Certificate - any name will do for example mycert.ca
I entered in the two letter country designator and all the fields down to unit but not sure that is necessary.
ensure you select the number of days you wish the cert to be valid (800 days or less)
The only two keys required under key usage are ‘key cert sign’ and ‘crl sign’
Self Sign it. The only entry in this menu will be the name in the top box, hit start and wait for it to stop.
There will be nothing appearing in the ISSUER box, this is ok!
Hit Apply, OK, done!
(2) Export this certificate in PEM format and and an at least an 8 digit passphrase 87654321 for example.
When you do it exports both a key and a crt (certificate). You only need the crt export file.
(3) Create vpn server certificate - any name will do but ensure its not the same as the common name (vpn.server) - so for ex. myvpn.server
ensure you select the number of days you wish the cert to be valid (800 days or less)
Enter in the common name ‘vpn.server’
Enter in the subj alternate name - DNS:myvpn.server (note you have to delete the two colons ':: ’ that already exists in the name block
The only two keys required under key usage are tls client and tls server
Sign the certificate using the the name of the certificate in the top box myvpn.server
and for the CA, the mycert.ca choice .
Hit start and when done, hit close, click on the trusted box that is now at the bottom of the screen and then hit apply and ok - done!
(4) Create vpn client certificate - any name will do but ensure its not the same as the common name (vpn.client) - so for ex. myvpn.client
ensure you select the number of days you wish the cert to be valid (800 days or less)
Enter in the common name ‘vpn.client’
Enter in the subj alternate name - DNS:myvpn.client (note you have to delete the two colons ':: ’ that already exists in the name block
The only two keys required under key usage are tls client and tls server
Sign the certificate using the the name of the certificate in the top box myvpn.client
and for the CA, the mycert.ca choice .
Hit start and when done, hit close, click on the trusted box that is now at the bottom of the screen and then hit apply and ok - done!
NOTE: for the server and client certificates, the alternate DNS name CANNOT be the same as the common name - thus DNS:myvpn.server (and not DNS:vpn.server)
(5) Export the myvpn.client certificate and use the PK format and an at least an 8 digit passphrase 87654321 for example.
IPHONE
Three locations on the phone are used:
a. Settings-General-Profiles (Profiles appears directly below VPN)
b. Settings-General-About - Trusted Certificates (last entry on the list)
c. Settings-General-VPN (VPN appears typically below Dictionary and above Profiles)
or just under Settings-VPN
(6) Move the mycert.ca certificate to the iphone and install -for me it automatically goes to Profiles.
Go to Profiles and click on the certificate (it has a generic name at this point cant remember)
It asks for the iphone password, and then you hit install and then it asks for your digit passphrase 87654321 and hit install and done etc…
You should see it successfully install in profiles with a green check mark for verified and displaying the correct name now (not the generic name) - mycert.ca
(7) Go to Trusted Certificates, your certificate should also be there mycert.ca and have an enable selection available. Enable the cert!
(8) Move the myvpn.client certificate to the iphone and install - for me it automatically goes to Profiles.
Go to Profiles and click on the certificate (it has a generic name at this point cant remember)
It asks for the iphone password, and then you hit install and then it asks for your digit passphrase 87654321 and hit install and done etc…
You should see it successfully install in profiles with a green check mark for verified and displaying the correct name now (not the above generic name) but I believe
the common name - vpn.client
(9) Go to the VPN location on the iphone (two location options noted above) and at the very bottom of the page is - add a new VPN configuration.
Type- IKEv2
Description - not critical I put something like IKEv2MTServer
Server - MT dydns name …mynetname.net
Remote ID - myvpn.server
Local ID - myvpn.client
Authentication - Use Certificate
Under Certificate - Select the option that reflects your certificate ( I believe here apple just used the common name - vpn.client)
(10) Later (in the steps) when doing the test connection dont use home wife turn it off so that its a cellular (external wan test).
MT ROUTER
a. I will assume you have setup the firewall correctly etc.
b. Will discuss the ip ipsec page
(11) PROFILE SETTING
name - we decided on myprofile
hash algorithm sha256
encryption algorithm aes256
DH group modp2048
proposal check obey
Limit I have 1 Day , not sure what is the norm here?
NAT Traversal is checked
DPD Traversal 3600, not sure what is the norm here?
DPD max failures 5 ?
(13) PEER setup
name - we decided on my-peer
address is 0.0.0.0/0.0
profile is - myprofile (name that matches setup item 12)
exchange mode ike2
Passive is checked
(14) MODE CONFIG
name we decided on iosconfig
responder checked
address pool - what you setup on the router already in ip pools for the ike vpn
address prefix length 32
static dns ( i have 9.9.9.9 ) you can put what you want I suppose.
(15) PROPOSAL
name we decided on myproposal (looks a bit like profile so confusing)
Auth algorithms sha256
Encr algorithms aes256cbc aes 256gcm
LIfetime: 00:30:00 not sure if this is the norm?
pfs group: modp2048
(16) POLICY (dynamically created)
Not sure if this is correct but I only modified the default and on the action page tab
action encrypt
ipsec protocol -esp
Proposal - name that matches myproposal ( already setup item 15)
Template Checked
Group - Default
(17) IDENTITIES
Is the biggie, I am not sure if order is important but in any case I have mine first (before any default).
Word of caution if you make changes to certificates this will change on you and thus have to reset this one, so keep a close eye on it LOL.
Peer entry matches a peer setup that is required - names should match “my-peer” (from item 13)
Authentication method - digital signature
Certificate - myvpn.server
Remote Certificate - myvpn.client
Policy group template (default) this points to another setup item and since you modified the default already, you are good to go!
my idtype fqdn
myid myvpn.server
remote ID type fqdn
remote id myvpn.client
match by remoteid
modeconfig - iosconfig (name that matches and points to setup item 14)
generate policy - port strict
TEST
ON MT turn on logs and also bring up ipsec active peers
Turn wifi on phone off
Select VPN on iphone
Change Status setting to connected…
You should see log activity , followed by an entry in the active peer AND NO RED LINES in the log!!
On the phone the connected status should remain (green).
One can now go to the MT APPLICATION on the IPHONE and login securely to your router for config purposes - assuming your MT router-firewall is prepared appropriately.