<?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 Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540448#M3364</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/285752"&gt;@Priyanka_Reddy&lt;/a&gt;, python 3.6 has been end-of-life and not receiving updates or security fixes since 2021 I believe, I strongly suggest upgrading&lt;/P&gt;</description>
    <pubDate>Fri, 28 Apr 2023 07:20:02 GMT</pubDate>
    <dc:creator>JimmyHolland</dc:creator>
    <dc:date>2023-04-28T07:20:02Z</dc:date>
    <item>
      <title>error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/539882#M3358</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;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ansible&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&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 nofollow noreferrer"&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_...&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 nofollow noreferrer"&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_T...&lt;/A&gt;"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;==============================================================&lt;/P&gt;&lt;P&gt;==============================================================&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;my client.py has the below snippet regarding the certfile, i am not sure , do i have to modify the cert__file variable?, if yes where?&amp;nbsp;&lt;/STRONG&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 10:14:25 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/539882#M3358</guid>
      <dc:creator>Priyanka_Reddy</dc:creator>
      <dc:date>2023-04-24T10:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/539883#M3359</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/285752"&gt;@Priyanka_Reddy&lt;/a&gt;, the reference documentation for the PAN-OS Ansible collection of modules is &lt;A href="https://paloaltonetworks.github.io/pan-os-ansible" target="_self"&gt;here&lt;/A&gt;, the security_rule modules specifically is &lt;A href="https://paloaltonetworks.github.io/pan-os-ansible/modules/panos_security_rule_module.html" target="_self"&gt;here&lt;/A&gt;. There are also tutorials and guides &lt;A href="https://pan.dev/ansible/docs/panos/" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding your first issue, the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;hip-profiles&lt;/FONT&gt; parameter is no longer used from PAN-OS 10.0 onwards because the Device-ID feature was released, so because you are using PAN-OS 10.2, please remove the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;hip_profiles: "something"&lt;/FONT&gt; line in your original playbook and that error should go away. You should then not need the subsequent XML API method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 10:27:52 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/539883#M3359</guid>
      <dc:creator>JimmyHolland</dc:creator>
      <dc:date>2023-04-24T10:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540168#M3361</link>
      <description>&lt;P&gt;Hi &lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/4294"&gt;@JimmyHolland&lt;/a&gt;&amp;nbsp;Jimmy,&lt;/P&gt;&lt;P&gt;Thank you for taking time and answering my query. The hip_profiles argument in security rume module is a default one. I have tried removing the&amp;nbsp;&lt;SPAN&gt;hip_profiles: "something", option in my original playbook, but still the playbook automatically takes default value as 'any' to hip_profile and send that to panaroma . Also the modules what you suggested to use need below requirements:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;P&gt;Python 3.8 or higher&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Ansible 2.9 or higher&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;If we upgrade our ansible version and python version, we are in fear that present scripts in ansible server wont work, as it happened once and we had to degrade the version of python in ansible server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-----------------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The ansible version we are using is :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[root@&amp;lt;&amp;gt; ~]# ansible --version&lt;BR /&gt;ansible 2.9.27&lt;BR /&gt;config file = /etc/ansible/ansible.cfg&lt;BR /&gt;configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']&lt;BR /&gt;ansible python module location = /usr/lib/python3.6/site-packages/ansible&lt;BR /&gt;executable location = /bin/ansible&lt;BR /&gt;python version = 3.6.8 (default, Jan 11 2023, 08:43:50) [GCC 8.5.0 20210514 (Red Hat 8.5.0-16)]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;--------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kindly suggest any workarounds related to the API error please.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 07:13:27 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540168#M3361</guid>
      <dc:creator>Priyanka_Reddy</dc:creator>
      <dc:date>2023-04-26T07:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540170#M3362</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/285752"&gt;@Priyanka_Reddy&lt;/a&gt;, which version of the PAN-OS collection are you using? &lt;A href="https://github.com/PaloAltoNetworks/pan-os-ansible/commit/77ff27df6c7bf8fe07de593ba4b13726530c9ed9" target="_self"&gt;There was an enhancement to cover the hip_profiles scenario in 2.10.0&lt;/A&gt;, are you using this version or higher?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 07:36:40 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540170#M3362</guid>
      <dc:creator>JimmyHolland</dc:creator>
      <dc:date>2023-04-26T07:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540447#M3363</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/4294"&gt;@JimmyHolland&lt;/a&gt;&amp;nbsp;I am using pan-python 0.18.0, as the python version in my ansible server is 3.6 and does not support pan-os collection which requires python 3.8 or higher.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 07:16:12 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540447#M3363</guid>
      <dc:creator>Priyanka_Reddy</dc:creator>
      <dc:date>2023-04-28T07:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540448#M3364</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/285752"&gt;@Priyanka_Reddy&lt;/a&gt;, python 3.6 has been end-of-life and not receiving updates or security fixes since 2021 I believe, I strongly suggest upgrading&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 07:20:02 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540448#M3364</guid>
      <dc:creator>JimmyHolland</dc:creator>
      <dc:date>2023-04-28T07:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: error: certfile should be a valid filesystem path</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540450#M3365</link>
      <description>&lt;P&gt;When we had a patching done on ansible server, the scripts didnt work, so we had to degrade the python version, anyway we wil try upgrading again and get back if the issue persists still&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 07:39:32 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/error-certfile-should-be-a-valid-filesystem-path/m-p/540450#M3365</guid>
      <dc:creator>Priyanka_Reddy</dc:creator>
      <dc:date>2023-04-28T07:39:32Z</dc:date>
    </item>
  </channel>
</rss>

