<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: error: certfile should be a valid filesystem path in Panorama Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/panorama-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/538905#M1477</link>
    <description>&lt;P&gt;Hi &lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/285752"&gt;@Priyanka_Reddy&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These errors are not PANW specific, but I will point you in the right direction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;With regard to the "Ansible: palo_security_rule module" error, all you need to do is find the right syntax.&amp;nbsp; A security policy rule can take a HIP Profile as an option, but the syntax is not correct.&lt;/LI&gt;
&lt;LI&gt;With regard to the API, the cert_file variable in the client.py Python script is incorrect.&amp;nbsp; It needs to be fixed.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
    <pubDate>Sun, 16 Apr 2023 11:14:14 GMT</pubDate>
    <dc:creator>TomYoung</dc:creator>
    <dc:date>2023-04-16T11:14:14Z</dc:date>
    <item>
      <title>error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/panorama-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/538772#M1476</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;I am trying to automate palo alto version 10.2.3-h2. Initially I tried to use Ansible: palo_security_rule module to push a security rule to palo alto, but I got error "hip_profiles unexpected here". The workaround for this error as looked up in google was to load current config in palo alto, which was not accepted as a feasible solution by my team.&lt;/P&gt;
&lt;P&gt;So I tried to use Ansible Api method to push the security rule to palo alto and I am getting this&amp;nbsp;error "&lt;STRONG&gt;msg": "Status code was -1 and not [200]: An unknown error occurred: certfile should be a valid filesystem path",&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I haven't got any workarounds for this error, and I didn't understand what this is related to. Can anyone please help me how can I fix this.&lt;/P&gt;
&lt;P&gt;Below is the script I have written in &lt;STRONG&gt;ansible&lt;/STRONG&gt; for pushing security rule.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- name: Get API key&lt;BR /&gt;uri:&lt;BR /&gt;url: https://{{ inventory_hostname }}/api/&lt;BR /&gt;method: GET&lt;BR /&gt;status_code: 200&lt;BR /&gt;validate_certs: no&lt;BR /&gt;use_proxy: no&lt;BR /&gt;return_content: yes&lt;BR /&gt;body_format: json&lt;BR /&gt;headers:&lt;BR /&gt;Content-Type: application/xml&lt;BR /&gt;body:&lt;BR /&gt;type: keygen&lt;BR /&gt;user: "{{ creds['username'] }}"&lt;BR /&gt;password: "{{ creds['password'] }}"&lt;BR /&gt;register: api_key_result1&lt;BR /&gt;delegate_to: localhost&lt;/P&gt;
&lt;P&gt;- name: print security key&lt;BR /&gt;shell: echo "{{ api_key_result.content }}" | grep -o -P '(?&amp;lt;=&amp;lt;key&amp;gt;).*(?=&amp;lt;/key&amp;gt;)'&lt;BR /&gt;register: key&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;- name: Create Security rule&lt;BR /&gt;uri:&lt;BR /&gt;url: 'https://&amp;lt;IP-ADDRESS&amp;gt;/restapi/v10.2/Policies/SecurityPreRules?location=vsys&amp;amp;vsys=&amp;lt;VALUE&amp;gt;&amp;amp;name=Ansible_Test_Rule'&lt;BR /&gt;client_key: "{{ key.stdout_lines }}"&lt;BR /&gt;method: POST&lt;BR /&gt;status_code: 200&lt;BR /&gt;body:&lt;BR /&gt;source: &amp;lt;&amp;gt;&lt;BR /&gt;destination: &amp;lt;&amp;gt;&lt;BR /&gt;service: "HTTPS"&lt;BR /&gt;body_format: json&lt;BR /&gt;headers:&lt;BR /&gt;Content-Type: application/xml&lt;BR /&gt;follow_redirects: all&lt;BR /&gt;return_content: yes&lt;BR /&gt;validate_certs: no&lt;BR /&gt;use_proxy: no&lt;BR /&gt;register: result&lt;/P&gt;
&lt;P&gt;========================================================&lt;/P&gt;
&lt;P&gt;ERROR:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt; File "/usr/lib64/python3.6/http/client.py", line 1422, in __init__&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;context.load_cert_chain(cert_file, key_file)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;TypeError: certfile should be a valid filesystem path&lt;/STRONG&gt;&lt;BR /&gt;fatal: [&amp;lt;IP&amp;gt;]: FAILED! =&amp;gt; {&lt;BR /&gt;"changed": false,&lt;BR /&gt;"content": "",&lt;BR /&gt;"elapsed": 0,&lt;BR /&gt;"invocation": {&lt;BR /&gt;"module_args": {&lt;BR /&gt;"attributes": null,&lt;BR /&gt;"backup": null,&lt;BR /&gt;"body": {&lt;BR /&gt;"destination": "&amp;lt;&amp;gt;",&lt;BR /&gt;"service": "HTTPS",&lt;BR /&gt;"source": "&amp;lt;IP&amp;gt;"&lt;BR /&gt;},&lt;BR /&gt;"body_format": "json",&lt;BR /&gt;"client_cert": null,&lt;BR /&gt;"client_key": "[&amp;lt;KEY&amp;gt;]",&lt;BR /&gt;"content": null,&lt;BR /&gt;"creates": null,&lt;BR /&gt;"delimiter": null,&lt;BR /&gt;"dest": null,&lt;BR /&gt;"directory_mode": null,&lt;BR /&gt;"follow": false,&lt;BR /&gt;"follow_redirects": "all",&lt;BR /&gt;"force": false,&lt;BR /&gt;"force_basic_auth": false,&lt;BR /&gt;"group": null,&lt;BR /&gt;"headers": {&lt;BR /&gt;"Content-Type": "application/xml"&lt;BR /&gt;},&lt;BR /&gt;"http_agent": "ansible-httpget",&lt;BR /&gt;"method": "POST",&lt;BR /&gt;"mode": null,&lt;BR /&gt;"owner": null,&lt;BR /&gt;"regexp": null,&lt;BR /&gt;"remote_src": null,&lt;BR /&gt;"removes": null,&lt;BR /&gt;"return_content": true,&lt;BR /&gt;"selevel": null,&lt;BR /&gt;"serole": null,&lt;BR /&gt;"setype": null,&lt;BR /&gt;"seuser": null,&lt;BR /&gt;"src": null,&lt;BR /&gt;"status_code": [&lt;BR /&gt;"200"&lt;BR /&gt;],&lt;BR /&gt;"timeout": 30,&lt;BR /&gt;"unix_socket": null,&lt;BR /&gt;"unsafe_writes": false,&lt;BR /&gt;"url": "&lt;A href="https://10.75.131.80/restapi/v10.2/Policies/SecurityPreRules?location=vsys&amp;amp;vsys=PDW-DC1-STR&amp;amp;name=Ansible_Test_Rule" target="_blank" rel="noopener"&gt;https://&amp;lt;IP&amp;gt;/restapi/v10.2/Policies/SecurityPreRules?location=vsys&amp;amp;vsys=&amp;lt;DEVICE-GROUP&amp;gt;&amp;amp;name=Ansible_Test_Rule&lt;/A&gt;",&lt;BR /&gt;"url_password": null,&lt;BR /&gt;"url_username": null,&lt;BR /&gt;"use_proxy": false,&lt;BR /&gt;"validate_certs": false&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;&lt;STRONG&gt;"msg": "Status code was -1 and not [200]: An unknown error occurred: certfile should be a valid filesystem path",&lt;/STRONG&gt;&lt;BR /&gt;"redirected": false,&lt;BR /&gt;"status": -1,&lt;BR /&gt;"url": "&lt;A href="https://10.75.131.80/restapi/v10.2/Policies/SecurityPreRules?location=vsys&amp;amp;vsys=PDW-DC1-STR&amp;amp;name=Ansible_Test_Rule" target="_blank" rel="noopener"&gt;https://&amp;lt;IP&amp;gt;/restapi/v10.2/Policies/SecurityPreRules?location=vsys&amp;amp;vsys=DEVICE-GROUP&amp;gt;&amp;amp;name=Ansible_Test_Rule&lt;/A&gt;"&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 13:37:12 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/panorama-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/538772#M1476</guid>
      <dc:creator>Priyanka_Reddy</dc:creator>
      <dc:date>2023-04-14T13:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/panorama-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/538905#M1477</link>
      <description>&lt;P&gt;Hi &lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/285752"&gt;@Priyanka_Reddy&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These errors are not PANW specific, but I will point you in the right direction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;With regard to the "Ansible: palo_security_rule module" error, all you need to do is find the right syntax.&amp;nbsp; A security policy rule can take a HIP Profile as an option, but the syntax is not correct.&lt;/LI&gt;
&lt;LI&gt;With regard to the API, the cert_file variable in the client.py Python script is incorrect.&amp;nbsp; It needs to be fixed.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2023 11:14:14 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/panorama-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/538905#M1477</guid>
      <dc:creator>TomYoung</dc:creator>
      <dc:date>2023-04-16T11:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/panorama-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/538939#M1478</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/77347"&gt;@TomYoung&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Can you please help me with the correct syntax of panos_security_rule,&amp;nbsp; making hip_profile as an option, in the first point mentioned by you.&lt;/P&gt;
&lt;P&gt;Regarding the API "&lt;SPAN&gt;the cert_file variable in the client.py Python script is incorrect" ::::: my client.py has the below snippet regarding the certfile, i am not sure where i have to modify the cert__file variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;===========&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;try:&lt;BR /&gt;import ssl&lt;BR /&gt;except ImportError:&lt;BR /&gt;pass&lt;BR /&gt;else:&lt;BR /&gt;class HTTPSConnection(HTTPConnection):&lt;BR /&gt;"This class allows communication via SSL."&lt;/P&gt;
&lt;P&gt;default_port = HTTPS_PORT&lt;/P&gt;
&lt;P&gt;# XXX Should key_file and cert_file be deprecated in favour of context?&lt;/P&gt;
&lt;P&gt;def __init__(self, host, port=None, key_file=None, cert_file=None,&lt;BR /&gt;timeout=socket._GLOBAL_DEFAULT_TIMEOUT,&lt;BR /&gt;source_address=None, *, context=None,&lt;BR /&gt;check_hostname=None):&lt;BR /&gt;super(HTTPSConnection, self).__init__(host, port, timeout,&lt;BR /&gt;source_address)&lt;BR /&gt;if (key_file is not None or cert_file is not None or&lt;BR /&gt;check_hostname is not None):&lt;BR /&gt;import warnings&lt;BR /&gt;warnings.warn("key_file, cert_file and check_hostname are "&lt;BR /&gt;"deprecated, use a custom context instead.",&lt;BR /&gt;DeprecationWarning, 2)&lt;BR /&gt;self.key_file = key_file&lt;BR /&gt;self.cert_file = cert_file&lt;BR /&gt;if context is None:&lt;BR /&gt;context = ssl._create_default_https_context()&lt;BR /&gt;# enable PHA for TLS 1.3 connections if available&lt;BR /&gt;if context.post_handshake_auth is not None:&lt;BR /&gt;context.post_handshake_auth = True&lt;BR /&gt;will_verify = context.verify_mode != ssl.CERT_NONE&lt;BR /&gt;if check_hostname is None:&lt;BR /&gt;check_hostname = context.check_hostname&lt;BR /&gt;if check_hostname and not will_verify:&lt;BR /&gt;raise ValueError("check_hostname needs a SSL context with "&lt;BR /&gt;"either CERT_OPTIONAL or CERT_REQUIRED")&lt;BR /&gt;if key_file or cert_file:&lt;BR /&gt;context.load_cert_chain(cert_file, key_file)&lt;BR /&gt;# cert and key file means the user wants to authenticate.&lt;BR /&gt;# enable TLS 1.3 PHA implicitly even for custom contexts.&lt;BR /&gt;if context.post_handshake_auth is not None:&lt;BR /&gt;context.post_handshake_auth = True&lt;BR /&gt;self._context = context&lt;BR /&gt;self._check_hostname = check_hostname&lt;/P&gt;
&lt;P&gt;def connect(self):&lt;BR /&gt;"Connect to a host on a given (SSL) port."&lt;/P&gt;
&lt;P&gt;super().connect()&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2023 07:00:40 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/panorama-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/538939#M1478</guid>
      <dc:creator>Priyanka_Reddy</dc:creator>
      <dc:date>2023-04-17T07:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/panorama-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/539360#M1485</link>
      <description>&lt;P&gt;Can anyone help me regarding the above query.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 12:51:04 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/panorama-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/539360#M1485</guid>
      <dc:creator>Priyanka_Reddy</dc:creator>
      <dc:date>2023-04-19T12:51:04Z</dc:date>
    </item>
  </channel>
</rss>

