Open somme8023 opened 7 years ago
On Mon, 24 Apr 2017, somme8023 wrote:
Use openssl to generate a certificate,when ikev1 is used, it can be used normally. When using ikev2, there is a problem that can not be used normally.
pluto[12107]: packet from 172.16.5.245:500: ikev2 cert encoding of IKEv2 Certificate Request Payload has an unknown value: 12 pluto[12107]: packet from 172.16.5.245:500: malformed payload in packet pluto[12107]: packet from 172.16.5.245:500: no-state: INVALID_EXCHANGE_TYPE pluto[12107]: packet from 172.16.5.245:500: ignored received packet with unknown cookies pluto[12107]: packet from 172.16.5.245:500: ignored received packet with unknown cookies pluto[12107]: packet from 172.16.5.245:500: ignored received packet with unknown cookies
Hmm, that seems like 4 bugs right there.
CERT handling in IKEv2 Wrong error code INVALID_EXCHANGE_TYPE No retransmit of retransmitted packets wrongly deleted state resulting in unknown cookies
Do you have the same CERT problem with libreswan?
Paul
Versions of Openswan up to and including 2.6.49 do not create/parse IKEv2 certificate requests properly. It was assumed (wrongly) that the structure was identical to IKEv1, which it is not. We already disabled sending a CR in a previous version, but neglected to ignore parsing them. The partial fix in 2.6.50 will be that we just ignore the payload, and 2.6.51 will fix things.
... actually, I miswrote. The structure is just fine. The error we previously observed involved the certificate payloads, during interoperation with strongswan. The problem in this case is that type=12, is not known to openswan, and the definition of the payload said that this was a critical issue. The simple fix for this is rather easy, which is to ignore the unknown types here. https://github.com/xelerance/Openswan/pull/239
@letoams Thank you. There is no use of Libswan, there is time to try.
@mcr Thank you.Waiting for repair version.
@somme8023 I will be creating a developer release tag this week. Would that be acceptable for you or would you prefer an actual 2.6.50 release?
@shussain I can accept it.
@shussain What bugs will the developer release tag fix?Have ipsec ikev2 with X.509's bug fixes?
@somme8023 The latest developer tag has been released. It contains various bug fixes including a bug fix for IKEv2 with X509. If you want a full list of bug and fixes, I can get that to you later on today (closer to 6pm EDT).
@shussain I don't need a full list of bug and fixes.I use this latest developer tag to test it.
@shussain I tested the IKEV1(with x509) and IKEV2(with x509) using Cisco routers and Openswan(developer release tag).
There was a problem when configuring to Ikev1 with x509,from pluto's print information, you can see that the ISAKMP SA is established, but the IPSec SA cannot be established. I used version (2.6.49.1) that is not problematic.
pluto[1579]: "IPSec_TUN_1" #1: I am sending a certificate request
pluto[1579]: "IPSec_TUN_1" #1: transition from state STATE_MAIN_I2 to state STATE_MAIN_I3
pluto[1579]: "IPSec_TUN_1" #1: STATE_MAIN_I3: sent MI3, expecting MR3
pluto[1579]: "IPSec_TUN_1" #1: Main mode peer ID is ID_DER_ASN1_DN: 'C=CN, OU=Robustel, CN=robustel.cisco.com'
pluto[1579]: "IPSec_TUN_1" #1: issuer cacert not found
pluto[1579]: "IPSec_TUN_1" #1: X.509 certificate rejected
pluto[1579]: "IPSec_TUN_1" #1: transition from state STATE_MAIN_I3 to state STATE_MAIN_I4
pluto[1579]: "IPSec_TUN_1" #1: STATE_MAIN_I4: ISAKMP SA established {auth=OAKLEY_RSA_SIG oursig= theirsig=AwEAAbFio cipher=oakley_3des_cbc_192 prf=oakley_md5 group=modp1024}
pluto[1579]: "IPSec_TUN_1" #1: Dead Peer Detection (RFC 3706): enabled
pluto[1579]: "IPSec_TUN_1" #2: initiating Quick Mode RSASIG+ENCRYPT+TUNNEL+UP+IKEv2ALLOW+SAREFTRACK {using isakmp#1 msgid:1e4d70a0 proposal=3DES(3)_192-MD5(1)_128 pfsgroup=no-pfs}
pluto[1579]: "IPSec_TUN_1" #2: ignoring informational payload, type IPSEC_RESPONDER_LIFETIME msgid=1e4d70a0
pluto[1579]: "IPSec_TUN_1" #2: ERROR: netlink response for Add SA esp.78dfc957@172.16.99.120 included errno 17: File exists
pluto[1579]: | setup_half_ipsec_sa() hit fail failed to add sa
pluto[1579]: "IPSec_TUN_1" #2: state #2: failed to setup incoming SA
pluto[1579]: packet from 172.16.5.245:500: phase 1 message is part of an unknown exchange
~ # pluto[1579]: "IPSec_TUN_1" #2: discarding duplicate packet; already STATE_QUICK_I1
pluto[1579]: packet from 172.16.5.245:500: phase 1 message is part of an unknown exchange
pluto[1579]: "IPSec_TUN_1" #2: discarding duplicate packet; already STATE_QUICK_I1
pluto[1579]: packet from 172.16.5.245:500: phase 1 message is part of an unknown exchange
When configured to IKEv2 with x509,from pluto's print information, you can see that there's a problem,the Child SA cannot be established.
pluto[1580]: loading secrets from "/etc/ipsec.secrets"
pluto[1580]: loaded private key file '/tmp/ipsec/Tunnel_1/private.key' (1679 bytes)
pluto[1580]: loaded private key for keyid: PPK_RSA:AwEAAcxXq/9E77 2AB3 9278 FEC7 F007 1850 91E7 E36B 7421 E7CF
pluto[1580]: | creating SPD to 172.16.99.120->spi=00000104@0.0.0.0 proto=61
pluto[1580]: | creating SPD to 172.16.99.120->spi=00000104@0.0.0.0 proto=61
pluto[1580]: "IPSec_TUN_1" #1: initiating v2 parent SA
pluto[1580]: "IPSec_TUN_1" #1: STATE_PARENT_I1: initiate
pluto[1580]: "IPSec_TUN_1" #1: transition from state STATE_IKEv2_START to state STATE_PARENT_I1
pluto[1580]: "IPSec_TUN_1" #1: STATE_PARENT_I1: sent v2I1, expected v2R1 (msgid: 00000000/00000000)
pluto[1580]: | I am sending my certificate
pluto[1580]: "IPSec_TUN_1" #2: transition from state STATE_PARENT_I1 to state STATE_PARENT_I2
pluto[1580]: "IPSec_TUN_1" #2: STATE_PARENT_I2: sent v2I2, expected v2R2 {auth=IKEv2 oursig=AwEAAcxXq theirsig= cipher=oakley_3des_cbc_192 integ=md5_96 prf=oakley_md5 group=modp1024} (msgid: 00000000/00000000)
pluto[1580]: packet from 172.16.5.245:500: missing payloads (within encryption) for v2_state: initiator-auth-process: ISAKMP_NEXT_v2SA+ISAKMP_NEXT_v2IDr+ISAKMP_NEXT_v2AUTH+ISAKMP_NEXT_v2TSi+ISAKMP_NEXT_v2TSr. Message dropped.
pluto[1580]: "IPSec_TUN_1" #2: STATE_CHILD_C0_KEYING: INVALID_EXCHANGE_TYPE
pluto[1580]: "IPSec_TUN_1" #2: max number of retransmissions (2) reached STATE_CHILD_C0_KEYING
pluto[1580]: "IPSec_TUN_1" #2: starting keying attempt 1 of an unlimited number
pluto[1580]: "IPSec_TUN_1" #2: deleting state #2 (STATE_CHILD_C0_KEYING)
pluto[1580]: pending Quick Mode with 172.16.5.245 "IPSec_TUN_1" took too long -- replacing phase 1
On Tue, 2 May 2017, somme8023 wrote:
pluto[1579]: "IPSec_TUN_1" #1: I am sending a certificate request pluto[1579]: "IPSec_TUN_1" #1: transition from state STATE_MAIN_I2 to state STATE_MAIN_I3 pluto[1579]: "IPSec_TUN_1" #1: STATE_MAIN_I3: sent MI3, expecting MR3 pluto[1579]: "IPSec_TUN_1" #1: Main mode peer ID is ID_DER_ASN1_DN: 'C=CN, OU=Robustel, CN=robustel.cisco.com' pluto[1579]: "IPSec_TUN_1" #1: issuer cacert not found pluto[1579]: "IPSec_TUN_1" #1: X.509 certificate rejected pluto[1579]: "IPSec_TUN_1" #1: transition from state STATE_MAIN_I3 to state STATE_MAIN_I4 pluto[1579]: "IPSec_TUN_1" #1: STATE_MAIN_I4: ISAKMP SA established {auth=OAKLEY_RSA_SIG oursig= theirsig=AwEAAbFio cipher=oakley_3des_cbc_192 prf=oakley_md5 group=modp1024}
I find it dangerously weird that a certificate is rejected, yet Main Mode authentication has succeeded... That looks like a pretty bad security issue.
pluto[1579]: "IPSec_TUN_1" #2: ERROR: netlink response for Add SA esp.78dfc957@172.16.99.120 included errno 17: File exists
That means the exact IPsec SA is already installed in the kernel by another conn.
pluto[1580]: "IPSec_TUN_1" #2: transition from state STATE_PARENT_I1 to state STATE_PARENT_I2 pluto[1580]: "IPSec_TUN_1" #2: STATE_PARENT_I2: sent v2I2, expected v2R2 {auth=IKEv2 oursig=AwEAAcxXq theirsig= ciph er=oakley_3des_cbc_192 integ=md5_96 prf=oakley_md5 group=modp1024} (msgid: 00000000/00000000) pluto[1580]: packet from 172.16.5.245:500: missing payloads (within encryption) for v2_state: initiator-auth-process : ISAKMP_NEXT_v2SA+ISAKMP_NEXT_v2IDr+ISAKMP_NEXT_v2AUTH+ISAKMP_NEXT_v2TSi+ISAKMP_NEXT_v2TSr. Message dropped. pluto[1580]: "IPSec_TUN_1" #2: STATE_CHILD_C0_KEYING: INVALID_EXCHANGE_TYPE
openswan does not display the Notify payloads when the state machine finds missing expected payloads. So you can only get to see the real error by enabling debugging and manually checking the notify payload received. (libreswan shows you the notify in those cases)
INVALID_EXCHANGE_TYPE looks like another bug where openswan picks the IKE_AUTH or IKE_INIT exchange for sending errors irrespective of the actual exchange received. Probably incomplete create_child_sa related code.
Paul
Paul Wouters (libreswan) notifications@github.com wrote:
I find it dangerously weird that a certificate is rejected, yet Main Mode authentication has succeeded... That looks like a pretty bad security issue.
Why? I can give you all sorts of certificates inband using IKE, and they should be ignored if they don't validate.
One can then continue on to verify the connection using some other credential.
> openswan does not display the Notify payloads when the state machine
> finds missing expected payloads. So you can only get to see the real
> error by enabling debugging and manually checking the notify payload
> received. (libreswan shows you the notify in those cases)
That's a good idea: glad you did that.
-- ] Never tell me the odds! | ipv6 mesh networks [ ] Michael Richardson, Sandelman Software Works | network architect [ ] mcr@sandelman.ca http://www.sandelman.ca/ | ruby on rails [
On May 3, 2017, at 17:34, Michael Richardson notifications@github.com wrote:
Paul Wouters (libreswan) notifications@github.com wrote:
I find it dangerously weird that a certificate is rejected, yet Main Mode authentication has succeeded... That looks like a pretty bad security issue.
Why? I can give you all sorts of certificates inband using IKE, and they should be ignored if they don't validate.
Sure, but there is no indication that you went on to a next CERT payload at all since you didn't print a validation success message, so I doubt that's what is happening here.
One can then continue on to verify the connection using some other credential.
Except openswan doesn't support multiple AUTH methods. There are some remnants of code supporting authby="rsasig|secret" but it breaks finding the host connection and I think is only partially supported with whack/libipsecconf by accident.
If certs are used the id->kind is set to cert, so it is very clear when it should even bother to read the CERT payload for validation and when to just ignore any CERT payload.
Use openssl to generate a certificate,when ikev1 is used, it can be used normally. When using ikev2, there is a problem that can not be used normally.
cisco routers and openswan are configured as follows
cisco routers config:
openswan config: /etc # cat /etc/ipsec.conf
cat ipsec.secrets : RSA /tmp/ipsec/Tunnel_1/private.key
What is the problem with my configuration?