jawj / IKEv2-setup

Set up Ubuntu Server 20.04 (or 18.04) as an IKEv2 VPN server
1.35k stars 338 forks source link

entered username and password is correct but 'user authentication failed' error is received #145

Closed emadbagheri96 closed 1 year ago

emadbagheri96 commented 2 years ago

Hi. First thanks alot for the script. For me it worked very well before the last setup I had but now I get "user authentication failed" error both on Android and Windows 10 client (which both worked fine before with another server setup). here is the log from the Android's StrongSwan:

Sep 6 12:10:26 00[DMN] +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Sep 6 12:10:26 00[DMN] Starting IKE service (strongSwan 5.9.3rc1, Android 12 - SKQ1.211006.001 test-keys/2022-06-01, M2012K11AG - POCO/alioth_eea/Xiaomi, Linux 4.19.157-perf-g17ea5704da62, aarch64) Sep 6 12:10:26 00[LIB] loaded plugins: androidbridge charon android-log openssl fips-prf random nonce pubkey chapoly curve25519 pkcs1 pkcs8 pem xcbc hmac socket-default revocation eap-identity eap-mschapv2 eap-md5 eap-gtc eap-tls x509 Sep 6 12:10:26 00[JOB] spawning 16 worker threads Sep 6 12:10:26 07[IKE] initiating IKE_SA android[5] to 185.110.188.169 Sep 6 12:10:26 07[ENC] generating IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(HASH_ALG) N(REDIR_SUP) ] Sep 6 12:10:26 07[NET] sending packet: from 192.168.2.114[48331] to 185.110.188.169[500] (716 bytes) Sep 6 12:10:27 10[NET] received packet: from 185.110.188.169[500] to 192.168.2.114[48331] (38 bytes) Sep 6 12:10:27 10[ENC] parsed IKE_SA_INIT response 0 [ N(INVAL_KE) ] Sep 6 12:10:27 10[IKE] peer didn't accept DH group ECP_256, it requested ECP_384 Sep 6 12:10:27 10[IKE] initiating IKE_SA android[5] to 185.110.188.169 Sep 6 12:10:27 10[ENC] generating IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(HASH_ALG) N(REDIR_SUP) ] Sep 6 12:10:27 10[NET] sending packet: from 192.168.2.114[48331] to 185.110.188.169[500] (748 bytes) Sep 6 12:10:27 11[NET] received packet: from 185.110.188.169[500] to 192.168.2.114[48331] (304 bytes) Sep 6 12:10:27 11[ENC] parsed IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(HASH_ALG) N(CHDLESS_SUP) N(MULT_AUTH) ] Sep 6 12:10:27 11[CFG] selected proposal: IKE:AES_GCM_16_256/PRF_HMAC_SHA2_384/ECP_384 Sep 6 12:10:27 11[IKE] local host is behind NAT, sending keep alives Sep 6 12:10:27 11[IKE] remote host is behind NAT Sep 6 12:10:27 11[CFG] loaded crl issued by 'C=US, O=Internet Security Research Group, CN=ISRG Root X1' Sep 6 12:10:27 11[IKE] sending cert request for "C=BM, O=QuoVadis Limited, CN=QuoVadis Root CA 2" Sep 6 12:10:27 11[IKE] sending cert request for "C=HU, L=Budapest, O=Microsec Ltd., CN=Microsec e-Szigno Root CA 2009, E=info@e-szigno.hu" Sep 6 12:10:27 11[IKE] sending cert request for "C=TW, O=TAIWAN-CA, OU=Root CA, CN=TWCA Root Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert High Assurance EV Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=PA, ST=Panama, L=Panama City, O=TrustCor Systems S. de R.L., OU=TrustCor Certificate Authority, CN=TrustCor RootCert CA-2" Sep 6 12:10:27 11[IKE] sending cert request for "C=JP, O=SECOM Trust.net, OU=Security Communication RootCA1" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=Texas, L=Houston, O=SSL Corporation, CN=SSL.com Root Certification Authority ECC" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert Assured ID Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=NL, O=Staat der Nederlanden, CN=Staat der Nederlanden EV Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=Illinois, L=Chicago, O=Trustwave Holdings, Inc., CN=Trustwave Global ECC P384 Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Internet Security Research Group, CN=ISRG Root X1" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Google Trust Services LLC, CN=GTS Root R2" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, OU=www.xrampsecurity.com, O=XRamp Security Services Inc, CN=XRamp Global Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=BM, O=QuoVadis Limited, CN=QuoVadis Root CA 3 G3" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert Assured ID Root G3" Sep 6 12:10:27 11[IKE] sending cert request for "C=FR, O=Dhimyotis, OU=0002 48146308100036, CN=Certigna Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=CH, O=SwissSign AG, CN=SwissSign Silver CA - G2" Sep 6 12:10:27 11[IKE] sending cert request for "C=PA, ST=Panama, L=Panama City, O=TrustCor Systems S. de R.L., OU=TrustCor Certificate Authority, CN=TrustCor RootCert CA-1" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Microsoft Corporation, CN=Microsoft ECC Root Certificate Authority 2017" Sep 6 12:10:27 11[IKE] sending cert request for "C=CN, O=China Financial Certification Authority, CN=CFCA EV ROOT" Sep 6 12:10:27 11[IKE] sending cert request for "C=JP, O=SECOM Trust Systems CO.,LTD., OU=Security Communication RootCA2" Sep 6 12:10:27 11[IKE] sending cert request for "O=Cybertrust, Inc, CN=Cybertrust Global Root" Sep 6 12:10:27 11[IKE] sending cert request for "OU=GlobalSign Root CA - R6, O=GlobalSign, CN=GlobalSign" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Entrust, Inc., OU=See www.entrust.net/legal-terms, OU=(c) 2015 Entrust, Inc. - for authorized use only, CN=Entrust Root Certification Authority - G4" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=AffirmTrust, CN=AffirmTrust Premium ECC" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert Trusted Root G4" Sep 6 12:10:27 11[IKE] sending cert request for "C=PL, O=Krajowa Izba Rozliczeniowa S.A., CN=SZAFIR ROOT CA2" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Google Trust Services LLC, CN=GTS Root R1" Sep 6 12:10:27 11[IKE] sending cert request for "C=IT, L=Milan, O=Actalis S.p.A./03358520967, CN=Actalis Authentication Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert Global Root G3" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=Texas, L=Houston, O=SSL Corporation, CN=SSL.com Root Certification Authority RSA" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=SecureTrust Corporation, CN=Secure Global CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=PL, O=Unizeto Technologies S.A., OU=Certum Certification Authority, CN=Certum Trusted Network CA 2" Sep 6 12:10:27 11[IKE] sending cert request for "OU=GlobalSign Root CA - R2, O=GlobalSign, CN=GlobalSign" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Entrust, Inc., OU=See www.entrust.net/legal-terms, OU=(c) 2012 Entrust, Inc. - for authorized use only, CN=Entrust Root Certification Authority - EC1" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, OU=emSign PKI, O=eMudhra Inc, CN=emSign Root CA - C1" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=Illinois, L=Chicago, O=Trustwave Holdings, Inc., CN=Trustwave Global Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=RO, O=CERTSIGN SA, OU=certSIGN ROOT CA G2" Sep 6 12:10:27 11[IKE] sending cert request for "C=NL, O=Staat der Nederlanden, CN=Staat der Nederlanden Root CA - G3" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=IdenTrust, CN=IdenTrust Commercial Root CA 1" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Network Solutions L.L.C., CN=Network Solutions Certificate Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=Arizona, L=Scottsdale, O=GoDaddy.com, Inc., CN=Go Daddy Root Certificate Authority - G2" Sep 6 12:10:27 11[IKE] sending cert request for "C=SK, L=Bratislava, O=Disig a.s., CN=CA Disig Root R2" Sep 6 12:10:27 11[IKE] sending cert request for "C=TR, L=Ankara, O=E-Tu??ra EBG Bili??im Teknolojileri ve Hizmetleri A.??., OU=E-Tugra Sertifikasyon Merkezi, CN=E-Tugra Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=AffirmTrust, CN=AffirmTrust Premium" Sep 6 12:10:27 11[IKE] sending cert request for "C=CN, O=GUANG DONG CERTIFICATE AUTHORITY CO.,LTD., CN=GDCA TrustAUTH R5 ROOT" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Amazon, CN=Amazon Root CA 2" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=SecureTrust Corporation, CN=SecureTrust CA" Sep 6 12:10:27 11[IKE] sending cert request for "OU=GlobalSign ECC Root CA - R4, O=GlobalSign, CN=GlobalSign" Sep 6 12:10:27 11[IKE] sending cert request for "C=NO, O=Buypass AS-983163327, CN=Buypass Class 2 Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=BM, O=QuoVadis Limited, CN=QuoVadis Root CA 1 G3" Sep 6 12:10:27 11[IKE] sending cert request for "O=TeliaSonera, CN=TeliaSonera Root CA v1" Sep 6 12:10:27 11[IKE] sending cert request for "C=BE, O=GlobalSign nv-sa, OU=Root CA, CN=GlobalSign Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=IN, OU=emSign PKI, O=eMudhra Technologies Limited, CN=emSign Root CA - G1" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Google Trust Services LLC, CN=GTS Root R3" Sep 6 12:10:27 11[IKE] sending cert request for "C=CH, O=SwissSign AG, CN=SwissSign Gold CA - G2" Sep 6 12:10:27 11[IKE] sending cert request for "C=EU, L=Madrid (see current address at www.camerfirma.com/address), serialNumber=A82743287, O=AC Camerfirma S.A., CN=Chambers of Commerce Root - 2008" Sep 6 12:10:27 11[IKE] sending cert request for "C=CH, O=WISeKey, OU=OISTE Foundation Endorsed, CN=OISTE WISeKey Global Root GC CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=TW, O=Chunghwa Telecom Co., Ltd., OU=ePKI Root Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=KR, O=NAVER BUSINESS PLATFORM Corp., CN=NAVER Global Root Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Amazon, CN=Amazon Root CA 1" Sep 6 12:10:27 11[IKE] sending cert request for "OU=GlobalSign ECC Root CA - R5, O=GlobalSign, CN=GlobalSign" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=AffirmTrust, CN=AffirmTrust Networking" Sep 6 12:10:27 11[IKE] sending cert request for "C=CN, O=UniTrust, CN=UCA Global G2 Root" Sep 6 12:10:27 11[IKE] sending cert request for "C=HK, O=Hongkong Post, CN=Hongkong Post Root CA 1" Sep 6 12:10:27 11[IKE] sending cert request for "O=Entrust.net, OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.), OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Certification Authority (2048)" Sep 6 12:10:27 11[IKE] sending cert request for "C=FR, O=Dhimyotis, CN=Certigna" Sep 6 12:10:27 11[IKE] sending cert request for "C=IN, OU=emSign PKI, O=eMudhra Technologies Limited, CN=emSign ECC Root CA - G3" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Amazon, CN=Amazon Root CA 3" Sep 6 12:10:27 11[IKE] sending cert request for "C=PL, O=Unizeto Technologies S.A., OU=Certum Certification Authority, CN=Certum Trusted Network CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Starfield Technologies, Inc., OU=Starfield Class 2 Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "OU=GlobalSign Root CA - R3, O=GlobalSign, CN=GlobalSign" Sep 6 12:10:27 11[IKE] sending cert request for "CN=Atos TrustedRoot 2011, O=Atos, C=DE" Sep 6 12:10:27 11[IKE] sending cert request for "C=DE, O=T-Systems Enterprise Services GmbH, OU=T-Systems Trust Center, CN=T-TeleSec GlobalRoot Class 2" Sep 6 12:10:27 11[IKE] sending cert request for "C=TR, L=Gebze - Kocaeli, O=Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK, OU=Kamu Sertifikasyon Merkezi - Kamu SM, CN=TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1" Sep 6 12:10:27 11[IKE] sending cert request for "C=GR, O=Hellenic Academic and Research Institutions Cert. Authority, CN=Hellenic Academic and Research Institutions RootCA 2011" Sep 6 12:10:27 11[IKE] sending cert request for "C=IE, O=Baltimore, OU=CyberTrust, CN=Baltimore CyberTrust Root" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Google Trust Services LLC, CN=GTS Root R4" Sep 6 12:10:27 11[IKE] sending cert request for "C=FI, O=Sonera, CN=Sonera Class2 CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=ES, CN=Autoridad de Certificacion Firmaprofesional CIF A62634068" Sep 6 12:10:27 11[IKE] sending cert request for "C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=BM, O=QuoVadis Limited, CN=QuoVadis Root CA 2 G3" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=GeoTrust Inc., OU=(c) 2007 GeoTrust Inc. - For authorized use only, CN=GeoTrust Primary Certification Authority - G2" Sep 6 12:10:27 11[IKE] sending cert request for "C=CH, O=WISeKey, OU=OISTE Foundation Endorsed, CN=OISTE WISeKey Global Root GB CA" Sep 6 12:10:27 11[IKE] sending cert request for "CN=ACCVRAIZ1, OU=PKIACCV, O=ACCV, C=ES" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=New Jersey, L=Jersey City, O=The USERTRUST Network, CN=USERTrust ECC Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO ECC Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=BM, O=QuoVadis Limited, OU=Root Certification Authority, CN=QuoVadis Root Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Amazon, CN=Amazon Root CA 4" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=IdenTrust, CN=IdenTrust Public Sector Root CA 1" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Entrust, Inc., OU=www.entrust.net/CPS is incorporated by reference, OU=(c) 2006 Entrust, Inc., CN=Entrust Root Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=VeriSign, Inc., OU=VeriSign Trust Network, OU=(c) 2008 VeriSign, Inc. - For authorized use only, CN=VeriSign Universal Root Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=Texas, L=Houston, O=SSL Corporation, CN=SSL.com EV Root Certification Authority ECC" Sep 6 12:10:27 11[IKE] sending cert request for "C=DE, O=T-Systems Enterprise Services GmbH, OU=T-Systems Trust Center, CN=T-TeleSec GlobalRoot Class 3" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=Texas, L=Houston, O=SSL Corporation, CN=SSL.com EV Root Certification Authority RSA R2" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert Global Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert Global Root G2" Sep 6 12:10:27 11[IKE] sending cert request for "C=CN, O=UniTrust, CN=UCA Extended Validation Root" Sep 6 12:10:27 11[IKE] sending cert request for "C=DE, O=D-Trust GmbH, CN=D-TRUST Root Class 3 CA 2 EV 2009" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=New Jersey, L=Jersey City, O=The USERTRUST Network, CN=USERTrust RSA Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=EU, L=Madrid (see current address at www.camerfirma.com/address), serialNumber=A82743287, O=AC Camerfirma S.A., CN=Global Chambersign Root - 2008" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, OU=emSign PKI, O=eMudhra Inc, CN=emSign ECC Root CA - C3" Sep 6 12:10:27 11[IKE] sending cert request for "C=BM, O=QuoVadis Limited, CN=QuoVadis Root CA 3" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Microsoft Corporation, CN=Microsoft RSA Root Certificate Authority 2017" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=The Go Daddy Group, Inc., OU=Go Daddy Class 2 Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=ES, O=IZENPE S.A., CN=Izenpe.com" Sep 6 12:10:27 11[IKE] sending cert request for "C=HU, L=Budapest, O=Microsec Ltd., 55:04:61=VATHU-23584497, CN=e-Szigno Root CA 2017" Sep 6 12:10:27 11[IKE] sending cert request for "C=HU, L=Budapest, O=NetLock Kft., OU=Tan??s??tv??nykiad??k (Certification Services), CN=NetLock Arany (Class Gold) F??tan??s??tv??ny" Sep 6 12:10:27 11[IKE] sending cert request for "C=PA, ST=Panama, L=Panama City, O=TrustCor Systems S. de R.L., OU=TrustCor Certificate Authority, CN=TrustCor ECA-1" Sep 6 12:10:27 11[IKE] sending cert request for "O=Digital Signature Trust Co., CN=DST Root CA X3" Sep 6 12:10:27 11[IKE] sending cert request for "C=ES, O=Agencia Catalana de Certificacio (NIF Q-0801176-I), OU=Serveis Publics de Certificacio, OU=Vegeu https://www.catcert.net/verarrel (c)03, OU=Jerarquia Entitats de Certificacio Catalanes, CN=EC-ACC" Sep 6 12:10:27 11[IKE] sending cert request for "C=GB, O=Trustis Limited, OU=Trustis FPS Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=NO, O=Buypass AS-983163327, CN=Buypass Class 3 Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=ES, O=FNMT-RCM, OU=AC RAIZ FNMT-RCM" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert Assured ID Root G2" Sep 6 12:10:27 11[IKE] sending cert request for "C=GR, L=Athens, O=Hellenic Academic and Research Institutions Cert. Authority, CN=Hellenic Academic and Research Institutions ECC RootCA 2015" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=Illinois, L=Chicago, O=Trustwave Holdings, Inc., CN=Trustwave Global ECC P256 Certification Authority" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=Entrust, Inc., OU=See www.entrust.net/legal-terms, OU=(c) 2009 Entrust, Inc. - for authorized use only, CN=Entrust Root Certification Authority - G2" Sep 6 12:10:27 11[IKE] sending cert request for "C=RO, O=certSIGN, OU=certSIGN ROOT CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=GB, ST=Greater Manchester, L=Salford, O=Comodo CA Limited, CN=AAA Certificate Services" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=Arizona, L=Scottsdale, O=Starfield Technologies, Inc., CN=Starfield Root Certificate Authority - G2" Sep 6 12:10:27 11[IKE] sending cert request for "C=TW, O=TAIWAN-CA, OU=Root CA, CN=TWCA Global Root CA" Sep 6 12:10:27 11[IKE] sending cert request for "C=DE, O=D-Trust GmbH, CN=D-TRUST Root Class 3 CA 2 2009" Sep 6 12:10:27 11[IKE] sending cert request for "C=HK, ST=Hong Kong, L=Hong Kong, O=Hongkong Post, CN=Hongkong Post Root CA 3" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, O=AffirmTrust, CN=AffirmTrust Commercial" Sep 6 12:10:27 11[IKE] sending cert request for "C=JP, O=Japan Certification Services, Inc., CN=SecureSign RootCA11" Sep 6 12:10:27 11[IKE] sending cert request for "C=GR, L=Athens, O=Hellenic Academic and Research Institutions Cert. Authority, CN=Hellenic Academic and Research Institutions RootCA 2015" Sep 6 12:10:27 11[IKE] sending cert request for "C=US, ST=Arizona, L=Scottsdale, O=Starfield Technologies, Inc., CN=Starfield Services Root Certificate Authority - G2" Sep 6 12:10:27 11[IKE] establishing CHILD_SA android{5} Sep 6 12:10:27 11[ENC] generating IKE_AUTH request 1 [ IDi N(INIT_CONTACT) CERTREQ CPRQ(ADDR ADDR6 DNS DNS6) N(ESP_TFC_PAD_N) SA TSi TSr N(MOBIKE_SUP) N(NO_ADD_ADDR) N(MULT_AUTH) N(EAP_ONLY) N(MSG_ID_SYN_SUP) ] Sep 6 12:10:27 11[ENC] splitting IKE message (3006 bytes) into 3 fragments Sep 6 12:10:27 11[ENC] generating IKE_AUTH request 1 [ EF(1/3) ] Sep 6 12:10:27 11[ENC] generating IKE_AUTH request 1 [ EF(2/3) ] Sep 6 12:10:27 11[ENC] generating IKE_AUTH request 1 [ EF(3/3) ] Sep 6 12:10:27 11[NET] sending packet: from 192.168.2.114[39076] to 185.110.188.169[4500] (1368 bytes) Sep 6 12:10:27 11[NET] sending packet: from 192.168.2.114[39076] to 185.110.188.169[4500] (1368 bytes) Sep 6 12:10:27 11[NET] sending packet: from 192.168.2.114[39076] to 185.110.188.169[4500] (396 bytes) Sep 6 12:10:29 14[IKE] retransmit 1 of request with message ID 1 Sep 6 12:10:29 14[NET] sending packet: from 192.168.2.114[39076] to 185.110.188.169[4500] (1368 bytes) Sep 6 12:10:29 14[NET] sending packet: from 192.168.2.114[39076] to 185.110.188.169[4500] (1368 bytes) Sep 6 12:10:29 14[NET] sending packet: from 192.168.2.114[39076] to 185.110.188.169[4500] (396 bytes) Sep 6 12:10:29 15[NET] received packet: from 185.110.188.169[4500] to 192.168.2.114[39076] (65 bytes) Sep 6 12:10:29 15[ENC] parsed IKE_AUTH response 1 [ N(AUTH_FAILED) ] Sep 6 12:10:29 15[IKE] received AUTHENTICATION_FAILED notify error

I'm sure that entered username & password is correct and tried to reinstall few times. One thing noticed in the log is 'remote host is behind NAT' but mine is NOT. Thanks in advance for your help.

jawj commented 2 years ago

I'm not sure why you're having these problems. Have you tried cat /etc/ipsec.secrets on the server to ensure your username and password are correct?

Also on the server, what do you see in sudo tail -f /var/log/syslog as you try to connect?

I think the NAT message is just a result of the use of 'forceencaps' in the server-side strongSwan config (see https://wiki.strongswan.org/projects/strongswan/wiki/connsection).

emadbagheri96 commented 2 years ago

Hi, Thanks for your help. Im sure that the entered password is correct and I double checked it with cat /etc/ipsec.secrets Here is the syslog

Sep 7 05:25:59 srv194863 charon: 15[NET] received packet: from 2.190.173.254[500] to 185.110.188.169[500] (376 bytes) Sep 7 05:25:59 srv194863 charon: 15[ENC] parsed IKE_SA_INIT request 0 [ SA KE No N(FRAG_SUP) N(NATD_S_IP) N(NATD_D_IP) V V V V ] Sep 7 05:25:59 srv194863 charon: 15[IKE] received MS NT5 ISAKMPOAKLEY v9 vendor ID Sep 7 05:25:59 srv194863 charon: 15[IKE] received MS-Negotiation Discovery Capable vendor ID Sep 7 05:25:59 srv194863 charon: 15[IKE] received Vid-Initial-Contact vendor ID Sep 7 05:25:59 srv194863 charon: 15[ENC] received unknown vendor ID: 01:52:8b:bb:c0:06:96:12:18:49:ab:9a:1c:5b:2a:51:00:00:00:02 Sep 7 05:25:59 srv194863 charon: 15[IKE] 2.190.173.254 is initiating an IKE_SA Sep 7 05:25:59 srv194863 charon: 15[CFG] selected proposal: IKE:AES_GCM_16_256/PRF_HMAC_SHA2_384/ECP_384 Sep 7 05:25:59 srv194863 charon: 15[IKE] remote host is behind NAT Sep 7 05:25:59 srv194863 charon: 15[ENC] generating IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(CHDLESS_SUP) N(MULT_AUTH) ] Sep 7 05:25:59 srv194863 charon: 15[NET] sending packet: from 185.110.188.169[500] to 2.190.173.254[500] (288 bytes) Sep 7 05:25:59 srv194863 charon: 16[NET] received packet: from 2.190.173.254[4500] to 185.110.188.169[4500] (572 bytes) Sep 7 05:25:59 srv194863 charon: 16[ENC] parsed IKE_AUTH request 1 [ EF(1/3) ] Sep 7 05:25:59 srv194863 charon: 16[ENC] received fragment #1 of 3, waiting for complete IKE message Sep 7 05:25:59 srv194863 charon: 06[NET] received packet: from 2.190.173.254[4500] to 185.110.188.169[4500] (572 bytes) Sep 7 05:25:59 srv194863 charon: 06[ENC] parsed IKE_AUTH request 1 [ EF(2/3) ] Sep 7 05:25:59 srv194863 charon: 06[ENC] received fragment #2 of 3, waiting for complete IKE message Sep 7 05:25:59 srv194863 charon: 05[NET] received packet: from 2.190.173.254[4500] to 185.110.188.169[4500] (556 bytes) Sep 7 05:25:59 srv194863 charon: 05[ENC] parsed IKE_AUTH request 1 [ EF(3/3) ] Sep 7 05:25:59 srv194863 charon: 05[ENC] received fragment #3 of 3, reassembled fragmented IKE message (1542 bytes) Sep 7 05:25:59 srv194863 charon: 05[ENC] parsed IKE_AUTH request 1 [ IDi CERTREQ N(MOBIKE_SUP) CPRQ(ADDR DNS NBNS SRV ADDR6 DNS6 SRV6) SA TSi TSr ] Sep 7 05:25:59 srv194863 charon: 05[IKE] received 63 cert requests for an unknown ca Sep 7 05:25:59 srv194863 charon: 05[CFG] looking for peer configs matching 185.110.188.169[%any]...2.190.173.254[192.168.1.156] Sep 7 05:25:59 srv194863 charon: 05[CFG] selected peer config 'roadwarrior' Sep 7 05:25:59 srv194863 charon: 05[IKE] initiating EAP_IDENTITY method (id 0x00) Sep 7 05:25:59 srv194863 charon: 05[IKE] peer supports MOBIKE Sep 7 05:25:59 srv194863 charon: 05[IKE] no private key found for 'dev1.noatrader.ir' Sep 7 05:25:59 srv194863 charon: 05[ENC] generating IKE_AUTH response 1 [ N(AUTH_FAILED) ] Sep 7 05:25:59 srv194863 charon: 05[NET] sending packet: from 185.110.188.169[4500] to 2.190.173.254[4500] (65 bytes)

from this:

Sep 7 05:25:59 srv194863 charon: 05[IKE] no private key found for 'dev1.noatrader.ir'

I found this one: https://lists.strongswan.org/pipermail/users/2010-June/000378.html and the output for my ipsec listcerts is this:

List of X.509 End Entity Certificates

subject: "CN=dev1.noatrader.ir" issuer: "C=US, O=Let's Encrypt, CN=R3" validity: not before Sep 06 07:26:39 2022, ok not after Dec 05 06:26:38 2022, ok (expires in 89 days) serial: 04:17:20:e7:bb:7a:e8:82:b6:36:8f:fc:62:a8:46:6c:cf:01 altNames: dev1.noatrader.ir flags: serverAuth clientAuth OCSP URIs: http://r3.o.lencr.org certificatePolicies: 2.23.140.1.2.1 1.3.6.1.4.1.44947.1.1.1 CPS: http://cps.letsencrypt.org authkeyId: 14:2e:b3:17:b7:58:56:cb:ae:50:09:40:e6:1f:af:9d:8b:14:c2:c6 subjkeyId: e7:55:b5:30:14:fa:3b:76:63:6d:bc:67:97:3c:c4:9d:f0:38:08:da pubkey: RSA 4096 bits keyid: f1:2e:25:28:d4:00:eb:a3:e5:e7:66:d4:9b:6e:9a:70:5e:f6:25:0c subjkey: e7:55:b5:30:14:fa:3b:76:63:6d:bc:67:97:3c:c4:9d:f0:38:08:da

which does not have "has private key" in front of pubkey as the link says... What should I do?

jawj commented 2 years ago

Right. When I run ipsec listcerts I get pubkey: RSA 4096 bits, has private key, so this seems to be your problem.

I guess this probably narrows the issue down to certbot and AppArmor.

First, are your certificates there?

certbot certificates ll /etc/ipsec.d/private ll /etc/letsencrypt/live/dev1.noatrader.ir/ ll /etc/letsencrypt/archive/dev1.noatrader.ir/

Next, it's probably worth checking whether strongSwan is giving any errors at startup time, when it tries to read your certificates. Run sudo tail -f /var/log/syslog, while issuing a sudo ipsec restart in another session.

emadbagheri96 commented 2 years ago

All the certificates seem to exist. certbot certificates

Saving debug log to /var/log/letsencrypt/letsencrypt.log


Found the following certs: Certificate Name: dev1.noatrader.ir Domains: dev1.noatrader.ir Expiry Date: 2022-12-05 06:26:38+00:00 (VALID: 88 days) Certificate Path: /etc/letsencrypt/live/dev1.noatrader.ir/fullchain.pem Private Key Path: /etc/letsencrypt/live/dev1.noatrader.ir/privkey.pem


ll /etc/ipsec.d/private

lrwxrwxrwx 1 root root 51 Sep 7 05:35 privkey.pem -> /etc/letsencrypt/live/dev1.noatrader.ir/privkey.pem

ll /etc/letsencrypt/live/dev1.noatrader.ir/

lrwxrwxrwx 1 root root 41 Sep 6 08:26 cert.pem -> ../../archive/dev1.noatrader.ir/cert1.pem lrwxrwxrwx 1 root root 42 Sep 6 08:26 chain.pem -> ../../archive/dev1.noatrader.ir/chain1.pem lrwxrwxrwx 1 root root 46 Sep 6 08:26 fullchain.pem -> ../../archive/dev1.noatrader.ir/fullchain1.pem lrwxrwxrwx 1 root root 44 Sep 6 08:26 privkey.pem -> ../../archive/dev1.noatrader.ir/privkey1.pem -rw-r--r-- 1 root root 692 Sep 6 08:26 README

ll /etc/letsencrypt/archive/dev1.noatrader.ir/

-rw-r--r-- 1 root root 2195 Sep 6 08:26 cert1.pem -rw-r--r-- 1 root root 3750 Sep 6 08:26 chain1.pem -rw-r--r-- 1 root root 5945 Sep 6 08:26 fullchain1.pem -rw------- 1 root root 3272 Sep 6 08:26 privkey1.pem

and here is the tail -f /var/log/syslog after ipsec restart

Sep 8 06:19:57 dev1 charon: 00[DMN] Starting IKE charon daemon (strongSwan 5.8.2, Linux 5.4.0-125-generic, x86_64) Sep 8 06:19:57 dev1 charon: 00[CFG] loading ca certificates from '/etc/ipsec.d/cacerts' Sep 8 06:19:57 dev1 charon: 00[CFG] loaded ca certificate "C=US, O=Let's Encrypt, CN=R3" from '/etc/ipsec.d/cacerts/chain.pem' Sep 8 06:19:57 dev1 charon: 00[CFG] loading aa certificates from '/etc/ipsec.d/aacerts' Sep 8 06:19:57 dev1 charon: 00[CFG] loading ocsp signer certificates from '/etc/ipsec.d/ocspcerts' Sep 8 06:19:57 dev1 charon: 00[CFG] loading attribute certificates from '/etc/ipsec.d/acerts' Sep 8 06:19:57 dev1 charon: 00[CFG] loading crls from '/etc/ipsec.d/crls' Sep 8 06:19:57 dev1 charon: 00[CFG] loading secrets from '/etc/ipsec.secrets' Sep 8 06:19:57 dev1 charon: 00[LIB] opening '/etc/ipsec.d/private/privkey.pem' failed: Permission denied Sep 8 06:19:57 dev1 charon: 00[LIB] building CRED_PRIVATE_KEY - RSA failed, tried 9 builders Sep 8 06:19:57 dev1 charon: 00[CFG] loading private key from '/etc/ipsec.d/private/privkey.pem' failed Sep 8 06:19:57 dev1 charon: 00[CFG] loaded EAP secret for xxxx Sep 8 06:19:57 dev1 charon: 00[CFG] loaded EAP secret for xxxx Sep 8 06:19:57 dev1 charon: 00[CFG] loaded 0 RADIUS server configurations Sep 8 06:19:57 dev1 charon: 00[CFG] HA config misses local/remote address Sep 8 06:19:57 dev1 kernel: [98392.072945] kauditd_printk_skb: 7 callbacks suppressed Sep 8 06:19:57 dev1 kernel: [98392.072946] audit: type=1400 audit(1662614397.683:68): apparmor="DENIED" operation="open" profile="/usr/lib/ipsec/charon" name="/etc/letsencrypt/archive/dev1.noatrader.ir/privkey1.pem" pid=8123 comm="charon" requested_mask="r" denied_mask="r" fsuid=0 ouid=0 Sep 8 06:19:57 dev1 charon: 00[LIB] loaded plugins: charon aesni aes rc2 sha2 sha1 md5 mgf1 random nonce x509 revocation constraints pubkey pkcs1 pkcs7 pkcs8 pkcs12 pgp dnskey sshkey pem openssl fips-prf gmp agent xcbc hmac gcm drbg attr kernel-netlink resolve socket-default connmark farp stroke updown eap-identity eap-aka eap-md5 eap-gtc eap-mschapv2 eap-dynamic eap-radius eap-tls eap-ttls eap-peap eap-tnc xauth-generic xauth-eap xauth-pam tnc-tnccs dhcp lookip error-notify certexpire led addrblock unity counters Sep 8 06:19:57 dev1 charon: 00[LIB] dropped capabilities, running as uid 0, gid 0 Sep 8 06:19:57 dev1 charon: 00[JOB] spawning 16 worker threads Sep 8 06:19:57 dev1 charon: 05[CFG] received stroke: add connection 'roadwarrior' Sep 8 06:19:57 dev1 charon: 05[CFG] adding virtual IP address pool 10.101.0.0/16 Sep 8 06:19:57 dev1 charon: 05[CFG] loaded certificate "CN=dev1.noatrader.ir" from 'cert.pem' Sep 8 06:19:57 dev1 charon: 05[CFG] added configuration 'roadwarrior' Sep 8 06:20:20 dev1 python3.8[651]: Stats for 08.09.2022 06:20:20

so the problem is opening '/etc/ipsec.d/private/privkey.pem' failed: Permission denied I searched a bit and found similar problems and the only way it worked was copying the original file from /etc/letsencrypt/archive/dev1.noatrader.ir/privkey1.pem to the /etc/ipsec.d/private/privkey.pem Now it Works Fine! It was a fun problem and Thanks alot for your help. My only remaining question is will it work after the certificats' 90 days renew ?

jawj commented 2 years ago

Good that this is fixed for now, but I think you'll find it will go wrong again in around 90 days when Let's Encrypt renews the certificate in /etc/letsencrypt/archive but your copied certificate expires.

Given the slightly later log line, ... apparmor="DENIED" ..., it looks like you have an AppArmor problem. This is meant to be fixed by the following part of the script, but something must be going wrong here.

grep -Fq 'jawj/IKEv2-setup' /etc/apparmor.d/local/usr.lib.ipsec.charon || echo "
# https://github.com/jawj/IKEv2-setup
/etc/letsencrypt/archive/${VPNHOST}/* r,
" >> /etc/apparmor.d/local/usr.lib.ipsec.charon

aa-status --enabled && invoke-rc.d apparmor reload

Can you check what you have in /etc/apparmor.d/local/usr.lib.ipsec.charon?

907th commented 1 year ago

@jawj I had the same problem today after re-running the ./setup.sh script with a different domain name. After doing this, the file /etc/apparmor.d/local/usr.lib.ipsec.charon still only contained a reference to the old letsencrypt certificate folder:

$ cat /etc/apparmor.d/local/usr.lib.ipsec.charon
# https://github.com/jawj/IKEv2-setup
/etc/letsencrypt/archive/OLD.DOMAIN.NAME/* r,

Solution: I appended this file with a path to the new letsencrypt certificate folder and the problem was fixed.