From: Jouni Malinen Date: Tue, 28 May 2019 10:47:15 +0000 (+0300) Subject: tests: PEM encoded ca_cert blob X-Git-Tag: hostap_2_9~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a0db3eb5d3b7f02eccf9709a80d130ff5c094a3;p=thirdparty%2Fhostap.git tests: PEM encoded ca_cert blob Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index 911baf61e..6e7741bc1 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -2197,11 +2197,32 @@ def test_ap_wpa2_eap_tls_pkcs12(dev, apdev): def test_ap_wpa2_eap_tls_pkcs12_blob(dev, apdev): """WPA2-Enterprise connection using EAP-TLS and PKCS#12 from configuration blob""" + cert = read_pem("auth_serv/ca.pem") + cacert = binascii.hexlify(cert).decode() + run_ap_wpa2_eap_tls_pkcs12_blob(dev, apdev, cacert) + +def test_ap_wpa2_eap_tls_pkcs12_blob_pem(dev, apdev): + """WPA2-Enterprise connection using EAP-TLS and PKCS#12 from configuration blob and PEM ca_cert blob""" + with open("auth_serv/ca.pem", "r") as f: + lines = f.readlines() + copy = False + cert = "" + for l in lines: + if "-----BEGIN" in l: + copy = True + if copy: + cert += l + if "-----END" in l: + copy = False + break + cacert = binascii.hexlify(cert.encode()).decode() + run_ap_wpa2_eap_tls_pkcs12_blob(dev, apdev, cacert) + +def run_ap_wpa2_eap_tls_pkcs12_blob(dev, apdev, cacert): check_pkcs12_support(dev[0]) params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hapd = hostapd.add_ap(apdev[0], params) - cert = read_pem("auth_serv/ca.pem") - if "OK" not in dev[0].request("SET blob cacert " + binascii.hexlify(cert).decode()): + if "OK" not in dev[0].request("SET blob cacert " + cacert): raise Exception("Could not set cacert blob") with open("auth_serv/user.pkcs12", "rb") as f: if "OK" not in dev[0].request("SET blob pkcs12 " + binascii.hexlify(f.read()).decode()):