Community discussions

MikroTik App
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

L2TP + IPSEC with certificate - problem

Tue May 07, 2019 1:59 am

Hi, I'm trying to put a VPN server using L2IP in conjunction with the certifications.
I do not use the IPsec wizard in the L2TP server settings. After performing the IPsec configuration using PSK everything works fine but with certificates I have a "no identity suits proposal" error.
It occurs on both Windows 10 and Android.

My config:
/ip ipsec profile
add dh-group=ecp256,ecp384,ecp521,ec2n185,ec2n155,modp8192,modp6144,modp4096,modp3072,modp2048,modp1536,modp1024,modp768 enc-algorithm=aes-256,camellia-256,aes-192,camellia-192,aes-128,camellia-128,3des,blowfish,des name=l2tp_profile
/ip ipsec peer
add name=peer1 passive=yes profile=l2tp_profile
/ip ipsec proposal
set [ find default=yes ] auth-algorithms=sha512,sha256,sha1,md5,null enc-algorithms=\
    aes-256-cbc,aes-256-ctr,aes-256-gcm,camellia-256,aes-192-cbc,aes-192-ctr,aes-192-gcm,camellia-192,aes-128-cbc,aes-128-ctr,aes-128-gcm,camellia-128,3des,blowfish,twofish,des,null pfs-group=none
/ppp profile
add name=L2TP use-compression=no use-encryption=required use-ipv6=no use-mpls=no use-upnp=no
/ip neighbor discovery-settings
set discover-interface-list=none
/interface l2tp-server server
set authentication=mschap2 default-profile=L2TP enabled=yes
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1
/ip ipsec identity
add auth-method=rsa-signature certificate=Server generate-policy=port-strict match-by=certificate notrack-chain=prerouting peer=peer1 remote-certificate=Client
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set ssh port=57185
set api disabled=yes
set api-ssl disabled=yes
/ppp secret
add local-address=10.10.10.1 name=wmanka password= profile=L2TP remote-address=10.10.10.2
/tool mac-server
set allowed-interface-list=none
/tool mac-server mac-winbox
set allowed-interface-list=none
/tool mac-server ping
set enabled=no


certificate print detail 
Flags: K - private-key, D - dsa, L - crl, C - smart-card-key, A - authority, I - issued, R - revoked, E - expired, T - trusted 
 0 K   A  T name="CA" digest-algorithm=sha256 country="PL" common-name="IP" key-size=8192 subject-alt-name="" days-valid=365 trusted=yes key-usage=key-cert-sign,crl-sign serial-number="5BAC4F56F5046670" 
            fingerprint="2afed65843fe8f73fc09623943b71057226c5f92f3ee29c3e618b39bda4300fa" invalid-before=may/06/2019 13:30:05 invalid-after=may/05/2020 13:30:05 expires-after=52w14h34m27s 

 1 K    I T name="Server" digest-algorithm=sha256 country="PL" common-name="IP" key-size=8192 subject-alt-name="" days-valid=365 trusted=yes key-usage=digital-signature,key-encipherment,data-encipherment,tls-server ca=CA 
            serial-number="09D94549811F2874" fingerprint="1ad16b1c7a1340d8b123e79cf17e1eafff2cf11fc8b2c074403ece99f6babf17" invalid-before=may/06/2019 13:49:50 invalid-after=may/05/2020 13:49:50 expires-after=52w14h54m12s 

 2 K    I   name="Client" digest-algorithm=sha256 country="PL" common-name="mail" key-size=8192 subject-alt-name="" days-valid=365 trusted=no key-usage=tls-client ca=CA serial-number="3D25B6C52192A1AF" 
            fingerprint="116a6c4e2448ae5fc9e940749369aa0c0e4380eb0a8443d55d77fce4eb422f97" invalid-before=may/06/2019 13:55:39 invalid-after=may/05/2020 13:55:39 expires-after=52w15h1s 

In log prom try to connect I have this:
22:52:54 ipsec,debug ===== received 408 bytes from
22:52:54 ipsec,debug,packet 0587cc63 31d27009 00000000 00000000 01100200 00000000 00000198 0d0000d4
22:52:54 ipsec,debug,packet 00000001 00000001 000000c8 01010005 03000028 01010000 80010007 800e0100
22:52:54 ipsec,debug,packet 80020002 80040014 80030003 800b0001 000c0004 00007080 03000028 02010000
22:52:54 ipsec,debug,packet 80010007 800e0080 80020002 80040013 80030003 800b0001 000c0004 00007080
22:52:54 ipsec,debug,packet 03000028 03010000 80010007 800e0100 80020002 8004000e 80030003 800b0001
22:52:54 ipsec,debug,packet 000c0004 00007080 03000024 04010000 80010005 80020002 8004000e 80030003
22:52:54 ipsec,debug,packet 800b0001 000c0004 00007080 00000024 05010000 80010005 80020002 80040002
22:52:54 ipsec,debug,packet 80030003 800b0001 000c0004 00007080 0d000018 01528bbb c0069612 1849ab9a
22:52:54 ipsec,debug,packet 1c5b2a51 00000001 0d000018 1e2b5169 05991c7d 7c96fcbf b587e461 00000009
22:52:54 ipsec,debug,packet 0d000014 4a131c81 07035845 5c5728f2 0e95452f 0d000014 90cb8091 3ebb696e
22:52:54 ipsec,debug,packet 086381b5 ec427b1f 0d000014 4048b7d5 6ebce885 25e7de7f 00d6c2d3 0d000014
22:52:54 ipsec,debug,packet fb1de3cd f341b7ea 16b7e5be 0855f120 0d000014 26244d38 eddb61b3 172a36e3
22:52:54 ipsec,debug,packet d0cfb819 00000014 e3a5966a 76379fe7 07228231 e5ce8652
22:52:54 ipsec,debug ===
22:52:54 ipsec,info respond new phase 1 (Identity Protection):
22:52:54 ipsec,debug begin.
22:52:54 ipsec,debug seen nptype=1(sa) len=212
22:52:54 ipsec,debug seen nptype=13(vid) len=24
22:52:54 ipsec,debug seen nptype=13(vid) len=24
22:52:54 ipsec,debug seen nptype=13(vid) len=20
22:52:54 ipsec,debug seen nptype=13(vid) len=20
22:52:54 ipsec,debug seen nptype=13(vid) len=20
22:52:54 ipsec,debug seen nptype=13(vid) len=20
22:52:54 ipsec,debug seen nptype=13(vid) len=20
22:52:54 ipsec,debug seen nptype=13(vid) len=20
22:52:54 ipsec,debug succeed.
22:52:54 ipsec,debug received unknown Vendor ID
22:52:54 ipsec,debug 01528bbb c0069612 1849ab9a 1c5b2a51 00000001
22:52:54 ipsec received long Microsoft ID: MS NT5 ISAKMPOAKLEY
22:52:54 ipsec received Vendor ID: RFC 3947
22:52:54 ipsec received Vendor ID: draft-ietf-ipsec-nat-t-ike-02\n
22:52:54 ipsec received Vendor ID: FRAGMENTATION
22:52:54 ipsec Fragmentation enabled
22:52:54 ipsec,debug received unknown Vendor ID
22:52:54 ipsec,debug fb1de3cd f341b7ea 16b7e5be 0855f120
22:52:54 ipsec,debug received unknown Vendor ID
22:52:54 ipsec,debug 26244d38 eddb61b3 172a36e3 d0cfb819
22:52:54 ipsec,debug received unknown Vendor ID
22:52:54 ipsec,debug e3a5966a 76379fe7 07228231 e5ce8652
22:52:54 ipsec CLIENT_IP Selected NAT-T version: RFC 3947
22:52:54 ipsec,debug total SA len=208
22:52:54 ipsec,debug 00000001 00000001 000000c8 01010005 03000028 01010000 80010007 800e0100
22:52:54 ipsec,debug 80020002 80040014 80030003 800b0001 000c0004 00007080 03000028 02010000
22:52:54 ipsec,debug 80010007 800e0080 80020002 80040013 80030003 800b0001 000c0004 00007080
22:52:54 ipsec,debug 03000028 03010000 80010007 800e0100 80020002 8004000e 80030003 800b0001
22:52:54 ipsec,debug 000c0004 00007080 03000024 04010000 80010005 80020002 8004000e 80030003
22:52:54 ipsec,debug 800b0001 000c0004 00007080 00000024 05010000 80010005 80020002 80040002
22:52:54 ipsec,debug 80030003 800b0001 000c0004 00007080
22:52:54 ipsec,debug begin.
22:52:54 ipsec,debug seen nptype=2(prop) len=200
22:52:54 ipsec,debug succeed.
22:52:54 ipsec,debug proposal #1 len=200
22:52:54 ipsec,debug begin.
22:52:54 ipsec,debug seen nptype=3(trns) len=40
22:52:54 ipsec,debug seen nptype=3(trns) len=40
22:52:54 ipsec,debug seen nptype=3(trns) len=40
22:52:54 ipsec,debug seen nptype=3(trns) len=36
22:52:54 ipsec,debug seen nptype=3(trns) len=36
22:52:54 ipsec,debug succeed.
22:52:54 ipsec,debug transform #1 len=40
22:52:54 ipsec,debug type=Encryption Algorithm, flag=0x8000, lorv=AES-CBC
22:52:54 ipsec,debug encryption(aes)
22:52:54 ipsec,debug type=Key Length, flag=0x8000, lorv=256
22:52:54 ipsec,debug type=Hash Algorithm, flag=0x8000, lorv=SHA
22:52:54 ipsec,debug hash(sha1)
22:52:54 ipsec,debug type=Group Description, flag=0x8000, lorv=384-bit random ECP group
22:52:54 ipsec,debug dh(ecp384)
22:52:54 ipsec,debug type=Authentication Method, flag=0x8000, lorv=RSA signatures
22:52:54 ipsec,debug type=Life Type, flag=0x8000, lorv=seconds
22:52:54 ipsec,debug type=Life Duration, flag=0x0000, lorv=4
22:52:54 ipsec,debug transform #2 len=40
22:52:54 ipsec,debug type=Encryption Algorithm, flag=0x8000, lorv=AES-CBC
22:52:54 ipsec,debug encryption(aes)
22:52:54 ipsec,debug type=Key Length, flag=0x8000, lorv=128
22:52:54 ipsec,debug type=Hash Algorithm, flag=0x8000, lorv=SHA
22:52:54 ipsec,debug hash(sha1)
22:52:54 ipsec,debug type=Group Description, flag=0x8000, lorv=256-bit random ECP group
22:52:54 ipsec,debug dh(ecp256)
22:52:54 ipsec,debug type=Authentication Method, flag=0x8000, lorv=RSA signatures
22:52:54 ipsec,debug type=Life Type, flag=0x8000, lorv=seconds
22:52:54 ipsec,debug type=Life Duration, flag=0x0000, lorv=4
22:52:54 ipsec,debug transform #3 len=40
22:52:54 ipsec,debug type=Encryption Algorithm, flag=0x8000, lorv=AES-CBC
22:52:54 ipsec,debug encryption(aes)
22:52:54 ipsec,debug type=Key Length, flag=0x8000, lorv=256
22:52:54 ipsec,debug type=Hash Algorithm, flag=0x8000, lorv=SHA
22:52:54 ipsec,debug hash(sha1)
22:52:54 ipsec,debug type=Group Description, flag=0x8000, lorv=2048-bit MODP group
22:52:54 ipsec,debug dh(modp2048)
22:52:54 ipsec,debug type=Authentication Method, flag=0x8000, lorv=RSA signatures
22:52:54 ipsec,debug type=Life Type, flag=0x8000, lorv=seconds
22:52:54 ipsec,debug type=Life Duration, flag=0x0000, lorv=4
22:52:54 ipsec,debug transform #4 len=36
22:52:54 ipsec,debug type=Encryption Algorithm, flag=0x8000, lorv=3DES-CBC
22:52:54 ipsec,debug encryption(3des)
22:52:54 ipsec,debug type=Hash Algorithm, flag=0x8000, lorv=SHA
22:52:54 ipsec,debug hash(sha1)
22:52:54 ipsec,debug type=Group Description, flag=0x8000, lorv=2048-bit MODP group
22:52:54 ipsec,debug dh(modp2048)
22:52:54 ipsec,debug type=Authentication Method, flag=0x8000, lorv=RSA signatures
22:52:54 ipsec,debug type=Life Type, flag=0x8000, lorv=seconds
22:52:54 ipsec,debug type=Life Duration, flag=0x0000, lorv=4
22:52:54 ipsec,debug transform #5 len=36
22:52:54 ipsec,debug type=Encryption Algorithm, flag=0x8000, lorv=3DES-CBC
22:52:54 ipsec,debug encryption(3des)
22:52:54 ipsec,debug type=Hash Algorithm, flag=0x8000, lorv=SHA
22:52:54 ipsec,debug hash(sha1)
22:52:54 ipsec,debug type=Group Description, flag=0x8000, lorv=1024-bit MODP group
22:52:54 ipsec,debug dh(modp1024)
22:52:54 ipsec,debug type=Authentication Method, flag=0x8000, lorv=RSA signatures
22:52:54 ipsec,debug type=Life Type, flag=0x8000, lorv=seconds
22:52:54 ipsec,debug type=Life Duration, flag=0x0000, lorv=4
22:52:54 ipsec,debug pair 1:
22:52:54 ipsec,debug 0x80bd938: next=(nil) tnext=0x80bcfc8
22:52:54 ipsec,debug 0x80bcfc8: next=(nil) tnext=0x80c02f0
22:52:54 ipsec,debug 0x80c02f0: next=(nil) tnext=0x80b4078
22:52:54 ipsec,debug 0x80b4078: next=(nil) tnext=0x80bd8c0
22:52:54 ipsec,debug 0x80bd8c0: next=(nil) tnext=(nil)
22:52:54 ipsec,debug proposal #1: 5 transform
22:52:54 ipsec,debug -checking with RSA signatures auth-
22:52:54 ipsec,debug prop#=1, prot-id=ISAKMP, spi-size=0, #trns=5
22:52:54 ipsec,debug trns#=1, trns-id=IKE
22:52:54 ipsec,debug type=Encryption Algorithm, flag=0x8000, lorv=AES-CBC
22:52:54 ipsec,debug type=Key Length, flag=0x8000, lorv=256
22:52:54 ipsec,debug type=Hash Algorithm, flag=0x8000, lorv=SHA
22:52:54 ipsec,debug type=Group Description, flag=0x8000, lorv=384-bit random ECP group
22:52:54 ipsec,debug type=Authentication Method, flag=0x8000, lorv=RSA signatures
22:52:54 ipsec,debug type=Life Type, flag=0x8000, lorv=seconds
22:52:54 ipsec,debug type=Life Duration, flag=0x0000, lorv=4
22:52:54 ipsec,debug -compare proposal #1: Local:Peer
22:52:54 ipsec,debug (lifetime = 86400:28800)
22:52:54 ipsec,debug (lifebyte = 0:0)
22:52:54 ipsec,debug enctype = AES-CBC:AES-CBC
22:52:54 ipsec,debug (encklen = 256:256)
22:52:54 ipsec,debug hashtype = SHA:SHA
22:52:54 ipsec,debug authmethod = RSA signatures:RSA signatures
22:52:54 ipsec,debug dh_group = 521-bit random ECP group:384-bit random ECP group
22:52:54 ipsec,debug -compare proposal #2: Local:Peer
22:52:54 ipsec,debug (lifetime = 86400:28800)
22:52:54 ipsec,debug (lifebyte = 0:0)
22:52:54 ipsec,debug enctype = AES-CBC:AES-CBC
22:52:54 ipsec,debug (encklen = 256:256)
22:52:54 ipsec,debug hashtype = SHA:SHA
22:52:54 ipsec,debug authmethod = RSA signatures:RSA signatures
22:52:54 ipsec,debug dh_group = 384-bit random ECP group:384-bit random ECP group
22:52:54 ipsec,error no identity suits proposal
22:52:54 ipsec,error CLIENT_IP failed to get valid proposal.
22:52:54 ipsec,error CLIENT_IP failed to pre-process ph1 packet (side: 1, status 1).
22:52:54 ipsec,error CLIENT_IP phase1 negotiation failed.

I have no idea what I'm doing wrong
Please help.
Last edited by WojtusW5 on Tue May 07, 2019 9:36 pm, edited 1 time in total.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Tue May 07, 2019 8:15 am

The log says that the Windows peer has sent 5 transforms in its proposal whereas the local:peer comparison ends with a final decision after just the second one which by all visible data matches (the mismatch in lifetime is not an issue because proposal-check is not set so the default value of obey is used).

So my qualified guess is that this proposal has been actually chosen (although one of the following lines in the log states otherwise) and the next step was to find a row in /ip ipsec identity matching the identity provided by the peer which failed.

The next qualified guess is about the reason of the failure. The log unfortunately doesn't show what type and value of the identity the peer has sent (this topic will hopefully help to find that out), but my guess is that it sends its hostname or IP address, which thus has to match the subject-alt-name of the certificate, and this field is empty in your client's certificate.

So to check that it is the right track of investigation, set remote-id in the /ip ipsec identity row to ignore and try again. If that helps, use the method above to find out what ID the peer sends, and generate a new certificate with a matching subject-alt-name.

Yet another issue may be the key-usage field of the client's certificate, tls-client may not be what the IPsec stack expects to see.

EDIT: already the first qualified guess was wrong. While what I wrote about the matching of certificate subject or alt-subject to peer id is true, Wireshark shows that the only received packet does not contain the peer ID, nor the certificate, so there is nothing to compare at that stage (and it's of course fine that the ID and certificate are not in the message, they have to be transported encrypted, otherwise anyone could spoof the identity if he could capture that message).

Another look into your configuration doesn't show anything suspicious to me, except the certificate's subject and alt-subject.

Does /ip ipsec identity print show any warning regarding the certificates used?
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem

Tue May 07, 2019 10:10 am

Unfortunately after changes:
1. Remote ID Type = ignore
2. Generating a new client certificate:

K I name="Client_new1" digest-algorithm=sha256 country="PL" common-name=MAIL key-size=8192 subject-alt-name="" days-valid=365 trusted=no
key-usage=ipsec-end-system,ipsec-tunnel,ipsec-user ca=CA serial-number="40E6EE992E9D9442" fingerprint="05eb8bce84c6ed8e84f75bc02a70bc0a77df9e3fb50c324778259c273bd28218"
invalid-before=may/07/2019 08:41:48 invalid-after=may/06/2020 08:41:48 expires-after=52w23h33m29s

Occurs the same problem
Last edited by WojtusW5 on Tue May 07, 2019 9:35 pm, edited 1 time in total.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Tue May 07, 2019 10:38 am

OK. So I've set up a test and found out that match-by=certificate is the reason; if I set it (the default value is remote-id), an otherwise working setup breaks the same way like yours.

You are affected by the issue, so it is your job to send that to support@mikrotik.com.

That doesn't necessarily mean that if you change just this you're good; while Mikrotik as an initiator sincerely ignores the key-usage value of the responder's certificate, it may not be the case with Windows.

Sadly, I wasn't able to make my Windows 10 even send the initial packet, so I cannot tell you what they send as an ID and whether they care about key-usage of the server's certificate or not.
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem

Tue May 07, 2019 10:52 am

OK. So I've set up a test and found out that match-by=certificate is the reason; if I set it (the default value is remote-id), an otherwise working setup breaks the same way like yours.

You are affected by the issue, so it is your job to send that to support@mikrotik.com.

That doesn't necessarily mean that if you change just this you're good; while Mikrotik as an initiator sincerely ignores the key-usage value of the responder's certificate, it may not be the case with Windows.

Sadly, I wasn't able to make my Windows 10 even send the initial packet, so I cannot tell you what they send as an ID and whether they care about key-usage of the server's certificate or not.

Thank You
I sent a ticket to support.
When I find out something I will write here.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Tue May 07, 2019 11:03 am

Still, if you set match-by=remote-id, you should get further, and the log might show the ID which the Windows client sends, so you could create a certificate with the proper subject-alt-name and be up and running long before Mikrotik fixes it. Search for peer's ID in the log, although it shows only the value, not the type of the ID.

Would be fine if you could post the result, or the whole log if it is too much for you to find also the ID type there using Wireshark.
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem

Tue May 07, 2019 11:36 am

Still, if you set match-by=remote-id, you should get further, and the log might show the ID which the Windows client sends, so you could create a certificate with the proper subject-alt-name and be up and running long before Mikrotik fixes it. Search for peer's ID in the log, although it shows only the value, not the type of the ID.

Would be fine if you could post the result, or the whole log if it is too much for you to find also the ID type there using Wireshark.

After changing match by on the remote id, the tunnel connects without any problem. But this solution does not make sense because you lose the ability to authorize the customer.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Tue May 07, 2019 12:58 pm

But this solution does not make sense because you lose the ability to authorize the customer.
Oh my. So it seems the bug is a more complex one. When you want to identify individual peers (and possibly provide individual treatment like policy-template-group and mode-config to them), a particular row in /ip ipsec identity has to be chosen either by the certificate itself or by the peer ID (authenticated using a certificate if auth-method=rsa-signature is chosen or by some other method otherwise). And to my understanding the bug is that the stack starts searching for the identity row too early, while it doesn't have the ID (or certificate) yet. So if you set match-by=certificate, it fails because it hasn't yet got the certificate to choose the row; if you set match-by=remote-id but provide no remote-id value, the /ip ipsec identity row can be chosen already at that moment because no information is missing; but if you set a particular remote-id value to the row, the row cannot be chosen at that moment because the stack hasn't got the ID value from the peer yet.

Mikrotik expressly states in the documentation that choice of /ip ipsec identity row by certificate is possible, and as the ID and certificate come in the same message, I think the intention is that both ways work and the reason why they fail is the same, the premature search for the row (or maybe only a premature termination of the negotiation if a matching row is not found at that moment).

So add this information to the ticket, or simply put a link to this topic there. I haven't found anything relevant in the change notes of 6.45beta so Mikrotik may not be aware of it yet.
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem

Tue May 07, 2019 1:28 pm

But this solution does not make sense because you lose the ability to authorize the customer.
Oh my. So it seems the bug is a more complex one. When you want to identify individual peers (and possibly provide individual treatment like policy-template-group and mode-config to them), a particular row in /ip ipsec identity has to be chosen either by the certificate itself or by the peer ID (authenticated using a certificate if auth-method=rsa-signature is chosen or by some other method otherwise). And to my understanding the bug is that the stack starts searching for the identity row too early, while it doesn't have the ID (or certificate) yet. So if you set match-by=certificate, it fails because it hasn't yet got the certificate to choose the row; if you set match-by=remote-id but provide no remote-id value, the /ip ipsec identity row can be chosen already at that moment because no information is missing; but if you set a particular remote-id value to the row, the row cannot be chosen at that moment because the stack hasn't got the ID value from the peer yet.

Mikrotik expressly states in the documentation that choice of /ip ipsec identity row by certificate is possible, and as the ID and certificate come in the same message, I think the intention is that both ways work and the reason why they fail is the same, the premature search for the row (or maybe only a premature termination of the negotiation if a matching row is not found at that moment).

So add this information to the ticket, or simply put a link to this topic there. I haven't found anything relevant in the change notes of 6.45beta so Mikrotik may not be aware of it yet.

You are so great that you have investigated it so thoroughly.
In the ticket I added a link to this thread so support will stay up to date with the information.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Tue May 07, 2019 5:48 pm

In the ticket I added a link to this thread so support will stay up to date with the information.
Nevertheless, would you mind finding out what ID type and value the Windows embedded client sends? It could be useful for others.

If you cannot find it there and don't want to publish the log here, let me know, I'll send my e-mail to the address you've leaked earlier.
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem

Tue May 07, 2019 11:51 pm

In the ticket I added a link to this thread so support will stay up to date with the information.
Nevertheless, would you mind finding out what ID type and value the Windows embedded client sends? It could be useful for others.

If you cannot find it there and don't want to publish the log here, let me know, I'll send my e-mail to the address you've leaked earlier.
Sure, I do not see a problem to throw it in, let me just say honestly, I do not know where to look for it
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Wed May 08, 2019 12:17 am

Sure, I do not see a problem to throw it in, let me just say honestly, I do not know where to look for it
Use the same /system logging settings you did before, set match-by=remote-id and remote-id=auto, run /log print follow-only file=ipsec-startup where topics~"ipsec", let the client successfully connect, break the /log print, download the file. If you want to hide your public IP (if any), be aware that it can be found in the decrypted raw packet data which are however necessary for the analysis, so substituting it only where it is visible in the text part of the log is not sufficient. So if you don't want to make it visible to all readers of this forum, say so and I'll send you an e-mail.

Off topic, at the moment IKEv2 seems to me to be a better option for Windows clients than L2TP - among other things because it is the only VPN where the client can receive from the server a list of subnets to be routed via the VPN. For all other VPN types, you can either make the tunnel the default route for all traffic, or you have to configure routes manually on the client. The same mechanism (DHCPINFORM) can be used also with L2TP but Mikrotik only supports it for IKEv2.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Wed May 08, 2019 12:27 am

...and, what might be much more interesting for you at the current state of affairs, the issue with identity matching by certificate doesn't exist with IKEv2 as I've just checked. So it is not so much off-topic after all.
 
stanego
just joined
Posts: 3
Joined: Tue Feb 05, 2019 6:36 am

Re: L2TP + IPSEC with certificate - problem

Wed May 08, 2019 2:49 am

Hola amigos. Tengo un problema con mi VPN.

Mi configuracion es como sigue.

Rb2011(A) - WAN recibe ip publica dinamica -----LAN es 192.168.2.254
Rb2011(B) - WAN recibe ip publica dinamica -----LAN es 192.168.1.254
RB1100AHX2 - 2 PUERTOS WAN que reciben ips de los RB arriba. PUERTO LAN es 192.168.51.1
Mimosa 192.168.51.20
AirFiber 192.168.51.22

Mi problema es que cree una red VPN para conectarme usando el RB2011(A), a este equipo me conecto sin problemas, pero no puedo acceder a mis equipos mimosa y airfiber. Les comento que todo esta conectado via cable ethernet. Y yo accedo a mi vpn desde mi casa.

Alguna solucion?
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem

Wed May 08, 2019 9:47 am

Hola amigos. Tengo un problema con mi VPN.

Mi configuracion es como sigue.

Rb2011(A) - WAN recibe ip publica dinamica -----LAN es 192.168.2.254
Rb2011(B) - WAN recibe ip publica dinamica -----LAN es 192.168.1.254
RB1100AHX2 - 2 PUERTOS WAN que reciben ips de los RB arriba. PUERTO LAN es 192.168.51.1
Mimosa 192.168.51.20
AirFiber 192.168.51.22

Mi problema es que cree una red VPN para conectarme usando el RB2011(A), a este equipo me conecto sin problemas, pero no puedo acceder a mis equipos mimosa y airfiber. Les comento que todo esta conectado via cable ethernet. Y yo accedo a mi vpn desde mi casa.

Alguna solucion?

Hi, write a new thread and describe exactly the configuration, type of VPN, log, etc.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Wed May 08, 2019 9:52 am

Mi problema es que cree una red VPN para conectarme usando el RB2011(A), a este equipo me conecto sin problemas, pero no puedo acceder a mis equipos mimosa y airfiber
...
Alguna solucion?
  1. su problema está relacionado con este tema solo de forma general, comience un tema nuevo, por favor
  2. el idioma de este foro es el inglés; usa un traductor automático si no confía en sus habilidades en inglés, y permita que traduzca el resultado del inglés al revés al español para verificar si el sentido no ha cambiado
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem

Wed May 08, 2019 11:19 am

Sure, I do not see a problem to throw it in, let me just say honestly, I do not know where to look for it
Use the same /system logging settings you did before, set match-by=remote-id and remote-id=auto, run /log print follow-only file=ipsec-startup where topics~"ipsec", let the client successfully connect, break the /log print, download the file. If you want to hide your public IP (if any), be aware that it can be found in the decrypted raw packet data which are however necessary for the analysis, so substituting it only where it is visible in the text part of the log is not sufficient. So if you don't want to make it visible to all readers of this forum, say so and I'll send you an e-mail.

Off topic, at the moment IKEv2 seems to me to be a better option for Windows clients than L2TP - among other things because it is the only VPN where the client can receive from the server a list of subnets to be routed via the VPN. For all other VPN types, you can either make the tunnel the default route for all traffic, or you have to configure routes manually on the client. The same mechanism (DHCPINFORM) can be used also with L2TP but Mikrotik only supports it for IKEv2.

I send the connection log in the attachment.
Configuration at the connect moment is:
/ip ipsec profile
add dh-group=ecp256,ecp384,ecp521,ec2n185,ec2n155,modp8192,modp6144,modp4096,modp3072,modp2048,modp1536,modp1024,modp768 enc-algorithm=\
    aes-256,camellia-256,aes-192,camellia-192,aes-128,camellia-128,3des,blowfish,des name=l2tp_profile
/ip ipsec peer
add name=peer1 passive=yes profile=l2tp_profile
/ip ipsec proposal
set [ find default=yes ] auth-algorithms=sha512,sha256,sha1,md5,null enc-algorithms="aes-256-cbc,aes-256-ctr,aes-256-gcm,camellia-256,aes-192-cbc,aes-192-ctr,\
    aes-192-gcm,camellia-192,aes-128-cbc,aes-128-ctr,aes-128-gcm,camellia-128,3des,blowfish,twofish,des,null" pfs-group=none
/ppp profile
add name=L2TP use-compression=no use-encryption=required use-ipv6=no use-mpls=no use-upnp=no
/interface l2tp-server server
set authentication=mschap2 default-profile=L2TP enabled=yes ipsec-secret=dupa12345
/ip ipsec identity
add auth-method=rsa-signature certificate=Server generate-policy=port-strict notrack-chain=prerouting peer=peer1 remote-certificate=Client
/ppp secret
add local-address=10.10.10.1 name=wmanka password= profile=L2TP remote-address=10.10.10.2
You do not have the required permissions to view the files attached to this post.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Wed May 08, 2019 1:39 pm

OK, so Wireshark says the certificate itself (or rather its informational part alone) is used as initiator ID - ID type: DER_ASN1_DN (9)

wireshark dissection code

Payload: Identification (5)
    Next payload: Certificate (6)
    Reserved: 00
    Payload length: 59
    ID type: DER_ASN1_DN (9)
    Protocol ID: Unused
    Port: Unused
    Identification Data:
    ID_DER_ASN1_DN: 0
        rdnSequence: 2 items (id-at-commonName=wojtek.manka.96<kvasnaryba>gmail.com,id-at-countryName=PL)
            RDNSequence item: 1 item (id-at-countryName=PL)
                RelativeDistinguishedName item (id-at-countryName=PL)
                    Id: 2.5.4.6 (id-at-countryName)
                    CountryName: PL
            RDNSequence item: 1 item (id-at-commonName=wojtek.manka.96<kvasnaryba>gmail.com)
                RelativeDistinguishedName item (id-at-commonName=wojtek.manka.96<kvasnaryba>gmail.com)
                    Id: 2.5.4.3 (id-at-commonName)
                    DirectoryString: uTF8String (4)
                        uTF8String: wojtek.manka.96<kvasnaryba>gmail.com
Which likely makes it impossible to separate the peer ID itself from its authentication by means of a certificate, so when the client certificate expires and you replace it by a new one at the client, you have to update the configuration also at the server with the new certificate to match on. The search for the row in /ip ipsec identity compares not only the DN part but also the rest of the certificate data - if you generate two certificates with the same common-name and subject-alt-name and sign them using two different CAs (because RouterOS won't let you sign two certificates with the same common-name by the same CA), and use one of them as remote-certificate of a row in /ip ipsec identity, you cannot set one at client's row in /ip ipsec identity at the server and the other one at the client although the DN part is the same in both. Any of the two works if set for use at both client and server side. I wonder whether it would be a security hole to match only on the DN of the remote-certificate and accept any valid certificate with the same DN?

The above applies to IKEv2 of course, it could not be tested with L2TP over IKE(v1) due to the bug, but the principle remains the same for both.
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem

Wed May 08, 2019 8:45 pm

OK, so Wireshark says the certificate itself (or rather its informational part alone) is used as initiator ID - ID type: DER_ASN1_DN (9)

wireshark dissection code

Payload: Identification (5)
    Next payload: Certificate (6)
    Reserved: 00
    Payload length: 59
    ID type: DER_ASN1_DN (9)
    Protocol ID: Unused
    Port: Unused
    Identification Data:
    ID_DER_ASN1_DN: 0
        rdnSequence: 2 items (id-at-commonName=wojtek.manka.96<kvasnaryba>gmail.com,id-at-countryName=PL)
            RDNSequence item: 1 item (id-at-countryName=PL)
                RelativeDistinguishedName item (id-at-countryName=PL)
                    Id: 2.5.4.6 (id-at-countryName)
                    CountryName: PL
            RDNSequence item: 1 item (id-at-commonName=wojtek.manka.96<kvasnaryba>gmail.com)
                RelativeDistinguishedName item (id-at-commonName=wojtek.manka.96<kvasnaryba>gmail.com)
                    Id: 2.5.4.3 (id-at-commonName)
                    DirectoryString: uTF8String (4)
                        uTF8String: wojtek.manka.96<kvasnaryba>gmail.com
Which likely makes it impossible to separate the peer ID itself from its authentication by means of a certificate, so when the client certificate expires and you replace it by a new one at the client, you have to update the configuration also at the server with the new certificate to match on. The search for the row in /ip ipsec identity compares not only the DN part but also the rest of the certificate data - if you generate two certificates with the same common-name and subject-alt-name and sign them using two different CAs (because RouterOS won't let you sign two certificates with the same common-name by the same CA), and use one of them as remote-certificate of a row in /ip ipsec identity, you cannot set one at client's row in /ip ipsec identity at the server and the other one at the client although the DN part is the same in both. Any of the two works if set for use at both client and server side. I wonder whether it would be a security hole to match only on the DN of the remote-certificate and accept any valid certificate with the same DN?

The above applies to IKEv2 of course, it could not be tested with L2TP over IKE(v1) due to the bug, but the principle remains the same for both.
Do I understand correctly Your anwer that using DER_ASN1_DN as the common name of a client certificate would theoretically allow L2TP + IPSEC to be connected to certificates ??
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Wed May 08, 2019 11:35 pm

Do I understand correctly Your anwer that using DER_ASN1_DN as the common name of a client certificate would theoretically allow L2TP + IPSEC to be connected to certificates ??
First, DER_ASN1_DN is just another name for the "common name" of the certificate.

As for what can be done, ask HoustonRedmond... I've spent some time today trying to understand how to link a "current user" certificate rather than "local machine" certificate to the Windows embedded VPN client for use with IKEv2 and failed miserably, and the configuration of the choice of "current user" certificate is the same for L2TP/IKE(v1) and for IKEv2 as in both cases it is used to authenticate a particular user rather than the whole client machine. Installing a "local machine" certificate is easy but I haven't found anywhere whether more than one can be installed and if yes, how the choice is made which one to use with which VPN connection. With "current user" certificate, you can associate a list of trusted CAs to a VPN connection, and the certificate is apparently chosen among those which have been signed by any of those selected CAs before contacting the responder, but what other attributes the certificate has to have to be eligible is a mystery to me yet. I've ended up with "A certificate could not be found that can be used with this Extensible Authentication Protocol" so far.

And worse than that, as Mikrotik hasn't provided any information related to use of "current user" certificates in their IPsec manual, I suspect it may not support this authentication method even for IKEv2 (let alone IKE+L2TP where the authentification using client certificate replaces the L2TP own authentification) even if I find how to use the "current user" certificate at the Windows end.

Important for you - use of DER_ASN1_DN as peer ID, which is what Windows did in your case (what were your exact settings at Windows side?), requires match-by=certificate to allow distinction between users; use of user-fqdn as remote-id type requires that certificate's alt-subject-name type is e-mail (and I have no idea what the common name has to be in that case). But in both cases, you bump into the same bug when IKE (v1) is used, and Windows cannot establish the SA for transport of the L2TP using IKEv2.
 
Sob
Forum Guru
Forum Guru
Posts: 9188
Joined: Mon Apr 20, 2009 9:11 pm

Re: L2TP + IPSEC with certificate - problem

Thu May 09, 2019 2:15 am

I believe that no support for EAP (and thus "current user" certificates) is current limitation of MikroTik's IKEv2.
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem

Thu May 09, 2019 7:34 am

I believe that no support for EAP (and thus "current user" certificates) is current limitation of MikroTik's IKEv2.
See the RouterOS test branch changelog:

MAJOR CHANGES IN v6.45:
----------------------
!) dot1x - added support for IEEE 802.1X Port-Based Network Access Control (CLI only);
!) ike2 - added support for EAP authentication methods (eap-tls, eap-ttls, eap-peap) as initiator (CLI only);
----------------------
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Thu May 09, 2019 10:13 am

!) ike2 - added support for EAP authentication methods (eap-tls, eap-ttls, eap-peap) as initiator (CLI only);
----------------------
In proper IPsec vernacular, initiator is what people are used to call client. So RouterOS can behave like the Windows machine, which is the opposite direction as compared to what we need.
 
Sob
Forum Guru
Forum Guru
Posts: 9188
Joined: Mon Apr 20, 2009 9:11 pm

Re: L2TP + IPSEC with certificate - problem

Thu May 09, 2019 3:06 pm

If they added one part, I'm sure that they will add another too. And then they can add it also to other places where it makes sense to have it, like User Manager, which would allow to get rid of external RADIUS for some things. Actually, I'm not sure about anything, just trying the power of suggestion thing, but it would definitely make sense.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Thu May 09, 2019 4:11 pm

Actually, I'm not sure about anything, just trying the power of suggestion thing, but it would definitely make sense.
And that's what I keep saying, in your part of the country the legal stimulatives must be much better than in mine. I've experienced a huge disappointment when I've tried to use User Manager as a Radius server for authentication of wireless clients, and I haven't noticed anything related to User Manager in changelog for months or years so I suppose it is currently far from development focus. On the other hand it is true that recently 802.1X has emerged all of a sudden, so the "server side" handling of EAP is being implemented, so adding support to User Manager would be a logical step.

Loosely related question, have you ever tried to install two "local machine" certificates on Windows issued by different CAs and see what happens?
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem

Thu May 09, 2019 4:15 pm

@sindy - I see that in general the solution to this problem that the certificate identifies the client will be difficult if at all possible.

@Sob - I also hope that EAP will also appear in other RouterOS sites.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Thu May 09, 2019 5:19 pm

@sindy - I see that in general the solution to this problem that the certificate identifies the client will be difficult if at all possible.
For the record, I've managed to click a proper combination of checkmarks in the "current user" certificate selection strategy form after all so Windows stopped complaining about inability to choose a certificate and have sent the initial request to Mikrotik. But it has taken me just a single step ahead as in that request, the peer ID was the IP address of the machine - ID_IPV4_ADDR which ROS 6.44.3 allows to set as my-id but not as remote-id. And the certificate was even not there because in the EAP workflow, the initiator's certificate is only used at latter stage, when the channel to RADIUS is established via the responder. So even when I've set remote-id to ignore, I've still got an error in the sense "identity could not be found" (because in that case, Mikrotik ignores the IDi parameter but expects the certificate to be present in the message).

Specially for L2TP over IPsec, the EAP handling of client authentification is more complex than for IKEv2: the authentification using user name and password is limited to the L2TP layer, while the authorization (without identification) is provided by the pre-shared key and limited to the IPsec layer; if machine certificates are used along with username and password, the mutual authentification of the server and the client machine using certificates is limited to IPsec layer as well. But with user certificates, there has to be an interaction between the L2TP layer and the IPsec layer at responder/server side, which is a complication which principially doesn't exist with IKEv2.

And given that there is no practical advantage in use of L2TP over IKE (v1) as compared to IKEv2 (the L2 bridging mode of L2TP is maybe supported on Linux but not on Windows or iOS), plus IKEv2 doesn't suffer from the annoying issue with handling multiple L2TP/IPsec clients behind the same public IP, I'll not be surprised if support of EAP for L2TP/IKE(v1) will come much later than for IKEv2, if at all.
 
Sob
Forum Guru
Forum Guru
Posts: 9188
Joined: Mon Apr 20, 2009 9:11 pm

Re: L2TP + IPSEC with certificate - problem

Thu May 09, 2019 5:25 pm

And that's what I keep saying, in your part of the country the legal stimulatives must be much better than in mine.
We hug trees here, well, some people do/did, I tried it only once and it didn't seem to do anything. But who knows, maybe it did and the effect is still present. :D
Loosely related question, have you ever tried to install two "local machine" certificates on Windows issued by different CAs and see what happens?
I experimented with various VPNs a year ago, but I put it away for a while, after suffering some disappointments. IKEv2's support only for machine certificates was one of them. It didn't work very well for me with one, so I never got to trying to have two. I understand from changelogs that things evolved since then, it looked like at least reliably telling one user from another should be now possible (but looking at this thread, maybe it needs few more tweaks). I didn't have enough time and mainly enthusiasm to play with it again (the place where I needed it got OpenVPN and even though we all know how MikroTik's implementation is, it works and users are happy), but I plan to do it.
 
WojtusW5
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Mon Oct 02, 2017 1:25 pm

Re: L2TP + IPSEC with certificate - problem  [SOLVED]

Thu May 23, 2019 3:24 pm

Hi,

However, it will not be possible to establish an L2TP + IPSEC with RSA connection. MikroTik does not plan to do this for IKEv1.
Below is the answer of the support:
"Currently we do not have plans to implement identity matching by certificate for IKEv1 main mode as it is not easy due to protocol limitations."

In this situation, IKEv2 remains to be used.
Last edited by WojtusW5 on Thu May 23, 2019 3:50 pm, edited 1 time in total.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11495
Joined: Mon Dec 04, 2017 9:19 pm

Re: L2TP + IPSEC with certificate - problem

Thu May 23, 2019 3:39 pm

In this situation, I want to stay with IPSEC, it remains IKEv2.
Przepraszam, nie zrozumiałem, co pan chciał tym powiedzieć :(
 
User avatar
emils
Forum Veteran
Forum Veteran
Posts: 906
Joined: Thu Dec 11, 2014 8:53 am

Re: L2TP + IPSEC with certificate - problem

Fri May 24, 2019 1:23 pm

Perhaps, you misinterpreted my e-mail or I worded it wrongly. To clarify:

It should be possible to establish L2TP over IPsec with RSA authentication.

What I meant with that quote is you can not use match-by=certificate to match a specific client certificate by a specific IPsec Identity. You can use a more generic identity with match-by=remote-id and not specifying the remote-certificate.