From e1062f5d267a6958708924e27470d1f9feaf2e50 Mon Sep 17 00:00:00 2001 From: Michael Gross Date: Wed, 25 Aug 2021 17:59:36 +0200 Subject: [PATCH] generate pfx and update firewall policy tests accordingly --- .../firewall/firewall_policy_resource_test.go | 27 ++-------- internal/services/firewall/testdata/HOWTO.md | 9 +++- .../services/firewall/testdata/cert_key.pem | 50 ------------------ .../firewall/testdata/certificate.pfx | Bin 0 -> 2517 bytes 4 files changed, 11 insertions(+), 75 deletions(-) delete mode 100644 internal/services/firewall/testdata/cert_key.pem create mode 100644 internal/services/firewall/testdata/certificate.pfx diff --git a/internal/services/firewall/firewall_policy_resource_test.go b/internal/services/firewall/firewall_policy_resource_test.go index 944183d7e78e..5c5adafe7012 100644 --- a/internal/services/firewall/firewall_policy_resource_test.go +++ b/internal/services/firewall/firewall_policy_resource_test.go @@ -470,7 +470,7 @@ resource "azurerm_key_vault_certificate" "test" { key_vault_id = azurerm_key_vault.test.id certificate { - contents = filebase64("testdata/cert_key.pem") + contents = filebase64("testdata/certificate.pfx") } certificate_policy { @@ -482,32 +482,11 @@ resource "azurerm_key_vault_certificate" "test" { exportable = true key_size = 2048 key_type = "RSA" - reuse_key = true + reuse_key = false } secret_properties { - content_type = "application/x-pem-file" - } - - x509_certificate_properties { - # Server Authentication = 1.3.6.1.5.5.7.3.1 - # Client Authentication = 1.3.6.1.5.5.7.3.2 - extended_key_usage = ["1.3.6.1.5.5.7.3.1"] - key_usage = [ - "cRLSign", - "dataEncipherment", - "digitalSignature", - "keyAgreement", - "keyCertSign", - "keyEncipherment", - ] - - subject_alternative_names { - dns_names = ["api.pluginsdk.io"] - } - - subject = "CN=api.pluginsdk.io" - validity_in_months = 1 + content_type = "application/x-pkcs12" } } diff --git a/internal/services/firewall/testdata/HOWTO.md b/internal/services/firewall/testdata/HOWTO.md index 5f2a6218a43d..0ec5e949e0f9 100644 --- a/internal/services/firewall/testdata/HOWTO.md +++ b/internal/services/firewall/testdata/HOWTO.md @@ -1,4 +1,11 @@ -# How Key and Certificate was generated +# How Certificates were generated + +## How Key and Certificate was generated ```bash openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem +``` + +## How PFX was generated from above Key and Certificate +```bash +openssl pkcs12 -export -out certificate.pfx -inkey key.pem -in cert.pem ``` \ No newline at end of file diff --git a/internal/services/firewall/testdata/cert_key.pem b/internal/services/firewall/testdata/cert_key.pem deleted file mode 100644 index d31bc9cac810..000000000000 --- a/internal/services/firewall/testdata/cert_key.pem +++ /dev/null @@ -1,50 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDkjCCAnoCCQDY1A4aUvTZ0TANBgkqhkiG9w0BAQsFADCBijELMAkGA1UEBhMC -Q0gxCzAJBgNVBAgMAlpIMQswCQYDVQQHDAJaSDESMBAGA1UECgwJVGVycmFmb3Jt -MQ4wDAYDVQQLDAVBenVyZTEYMBYGA1UEAwwPd3d3LmNvbnRvc28uY29tMSMwIQYJ -KoZIhvcNAQkBFhR3aGF0ZXZlckBjb250b3NvLmNvbTAeFw0yMTA0MjIxOTU4MTBa -Fw0zMTA0MjAxOTU4MTBaMIGKMQswCQYDVQQGEwJDSDELMAkGA1UECAwCWkgxCzAJ -BgNVBAcMAlpIMRIwEAYDVQQKDAlUZXJyYWZvcm0xDjAMBgNVBAsMBUF6dXJlMRgw -FgYDVQQDDA93d3cuY29udG9zby5jb20xIzAhBgkqhkiG9w0BCQEWFHdoYXRldmVy -QGNvbnRvc28uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5rx3 -fTN0UUV1ktetzM2AEIJ4ZKQlibrLtVORPX2LQp2Vl/n74DPD2Re/ZgO2NtjhjItY -O65ZSqOgGz3R8ED4r12AokLCFmqhBnnr4IybeaQos7prjLKwSIyj5NbVMGuzNO6P -55W1zTMfV+CstbCtXtRPa7zizXjYbT3dfpw8FgJLh9sVWaiCO34Nu9PWF9NRIlzI -e/Ek3ss/JnNqskH+xnxgxq68slaZa4qojBjiLl/IdIs4A9DtyJnFd99xuh8nShMg -4ykccPr9/+YBaz8/Ef7/zmXj3g9DLTrIa7JV6s80V5oVINaF7KXu9jmjD+a03SsR -/8eKX6K+xDBtqxpz8wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAOGe2knCVxje06 -ihfhzprg7lTM7GCgiXqa4fdCVwq0hJAYpMg29F7Df3OE/zVD/mzdRWZe2yVTY47f -YFEfDKMmkGepgqICs0wTfhBSham8vkk2yDcoT01Lar+Im3GToP3JSM5YFbqxam0R -/AVskE5aHQ+tIGUwcuwWhjjKQuWua59tI0USjgGaK3cZ5tyFOQPcE3ZFzndWM3Rz -ojNHH5UJOT7zt4RebBzGRpcNdrbkOtVkRVZIwH0wJfm44zR+L36UhpXUd8XGKvua -KFlqJhw/8UtYzXXX5bwHb/JTkOLUbs8gobG23lFhxXG5QhqtwqYnHXRw9Jhclv8p -weEgmhnj ------END CERTIFICATE----- ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDmvHd9M3RRRXWS -163MzYAQgnhkpCWJusu1U5E9fYtCnZWX+fvgM8PZF79mA7Y22OGMi1g7rllKo6Ab -PdHwQPivXYCiQsIWaqEGeevgjJt5pCizumuMsrBIjKPk1tUwa7M07o/nlbXNMx9X -4Ky1sK1e1E9rvOLNeNhtPd1+nDwWAkuH2xVZqII7fg2709YX01EiXMh78STeyz8m -c2qyQf7GfGDGrryyVplriqiMGOIuX8h0izgD0O3ImcV333G6HydKEyDjKRxw+v3/ -5gFrPz8R/v/OZePeD0MtOshrslXqzzRXmhUg1oXspe72OaMP5rTdKxH/x4pfor7E -MG2rGnPzAgMBAAECggEAAXJvIWbgNN5FpX0axu0G/5OB48evwJReUK3MfGE8LVfF -p2VW8goBEWx3s9EUJHXpvDLng8BNKQ2rpGAX3/TYWmkwtFPM2c0jY2ICW68mDnY8 -Fxx1LjW0q0/Oe1HpllsmjY9tcZtbv4SxjqCHFMC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5jmZh6bPSYc= ------END PRIVATE KEY----- diff --git a/internal/services/firewall/testdata/certificate.pfx b/internal/services/firewall/testdata/certificate.pfx new file mode 100644 index 0000000000000000000000000000000000000000..cbf0f300daebf9066003876079b8c26512e8bc7d GIT binary patch literal 2517 zcmY+^cQhM}8U}D9M3fYtO;fb=Luo?oR;6auu9{a=P}C)Aq-sVGYHt-IK~U-=)M)Kl zv$Yy^QEFC0RgGA2bA9LBd%t`Cc+Y#z^PKbi`GaCX6D-WEP%J2y9VCY{!X0um1DT0f zP&@z&iaC!lP%J?0uZo?B1^j*eLr_Ergxl&)V8db|iut?GLcW@7J{cZ6no|tQqJ58F6IV&*&3EZJCv&qHBU;Ub ze(9B*?T|!Srn0)!cP(4bH*rlsLHB$Fzhn=`g}Mv`Jd<~Uw0Kk=rE{blJPLnMQu;#% zJGGg+cMYy**HYU84&PT?`n9nRTawO_!=Ih*VGuGvC+2K_plWDd0gwe zv-s1(Y-RD?@;EGx^o3B8z(&^}P+)Pq)#>sCIWBhP!9U|u{pKi5^RPOFX2{ZV(LlRB zqvMW4YVX@-xo;`$O2w1(uC_<7W-gbX2&w=d7o}@HwpIH8r*LSCH}Koo^cK2EmI(Um zq11H&23)!ZmR)CvzEYSiXt7-B%vV2;#j!9)zAvn(AWWKLbXq+ZFO?`Y2;`TJclVLK z6eyioR_nxJ;QafN@TBGayxqOHj{3_xK11?;K8II@_@4f~*ury(4{$?cFZQCWo;@U5 z57!v}yfYBh*!E77YkJDHsQD4MNTkWeSg0e!#-gg?HhFpMAGbh5+F0LuW;;#sVfQsR zW>zzt-IqCJ9%-ttp(aoDZM?f~jZo|f&0Ukfq2{X9-0B>^bqg5qa{@_SnW16|Rs6=L zYZ#WT0a1|#Zt$JQgfrD#p2&o==*=qg5;kL-ds|x{b!RoV5MEv%4qQl~-kh7}h*W2* zVRF_$Ngb(ax%dymYVVu8Yt37j zT*(>zz-3xkgul&tq~unkS$73Cy3UJLkoIZOkb78bC^fAC{i|mvVP~G@_5qG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