<?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>idea Fetch client certificate from Windows cert store using arcpy in Python Ideas</title>
    <link>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idi-p/1115342</link>
    <description>&lt;P&gt;I would like a way to fetch a user's client certificate from the Windows cert store, for authenticating to protected web services within geoprocessing tools.&lt;/P&gt;&lt;P&gt;Previously I had done this using pythonnet but pythonnet is [still? lately? unreliably?] unsupported in python scripts when used as geoprocessing tools.&lt;/P&gt;&lt;P&gt;For those of us working in "extremely security conscious" environments, being able to extend ArcGIS Pro to integrate protected web services, without interfering with a user's workflow, and without having to use the .NET SDK, is a critical need.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Nov 2021 18:03:43 GMT</pubDate>
    <dc:creator>EricEagle</dc:creator>
    <dc:date>2021-11-09T18:03:43Z</dc:date>
    <item>
      <title>Fetch client certificate from Windows cert store using arcpy</title>
      <link>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idi-p/1115342</link>
      <description>&lt;P&gt;I would like a way to fetch a user's client certificate from the Windows cert store, for authenticating to protected web services within geoprocessing tools.&lt;/P&gt;&lt;P&gt;Previously I had done this using pythonnet but pythonnet is [still? lately? unreliably?] unsupported in python scripts when used as geoprocessing tools.&lt;/P&gt;&lt;P&gt;For those of us working in "extremely security conscious" environments, being able to extend ArcGIS Pro to integrate protected web services, without interfering with a user's workflow, and without having to use the .NET SDK, is a critical need.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 18:03:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idi-p/1115342</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2021-11-09T18:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch client certificate from Windows cert store using arcpy</title>
      <link>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1115556#M88</link>
      <description>&lt;P&gt;Looks like you can use&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&lt;A title="ssl" href="https://docs.python.org/3/library/ssl.html#ssl.enum_certificates" target="_blank" rel="noopener"&gt;ssl.enum_certificates&lt;/A&gt;&lt;/FONT&gt; &amp;nbsp;to fetch certs.&amp;nbsp; Here's an example using ArcGIS Pro 2.8 arcgispro-py3 env (which includes the cryptography package v 2.8):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import ssl
from cryptography import x509
from cryptography.hazmat.backends import default_backend  # cryptography &amp;lt; 3.1 https://cryptography.io/en/latest/faq/?highlight=backend#what-happened-to-the-backend-argument

for store in ["CA", "ROOT", "MY"]:
    for cert, encoding, trust in ssl.enum_certificates(store):
        certificate = x509.load_der_x509_certificate(cert, backend=default_backend())   # cryptography &amp;lt; 3.1 
        # certificate = x509.load_der_x509_certificate(cert)   # cryptography &amp;gt;= 3.1 
        print(certificate.issuer, certificate.not_valid_after)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 23:22:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1115556#M88</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-11-10T23:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch client certificate from Windows cert store using arcpy</title>
      <link>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1117430#M90</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10780"&gt;@Luke_Pinner&lt;/a&gt; thanks, however this does not give me the user's personal digital signing certificate, only the cert authorities.... I feel like this moves me closer, but basically I'd need to know how to go from getting that personal signing certificate object, and then sending it via a library like requests or requests_pkcs12 to authenticate/authorize a session.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 20:54:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1117430#M90</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2021-11-16T20:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch client certificate from Windows cert store using arcpy</title>
      <link>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1200681#M134</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/171761"&gt;@EricEagle&lt;/a&gt;&amp;nbsp;I believe from the "MY" store in Luke's example you should be able to get down to the users' provided certificates. For a more fully worked example, see for example &lt;A href="https://blog.darrenjrobinson.com/accessing-the-windows-certificate-store-using-python/" target="_self"&gt;this post&lt;/A&gt;. I'm not aware of any direct core functionality in our software that provides this, so I don't think there is something internal for us to expose via ArcPy, is that consistent with your understanding? If so, I think probably trying to get our collection of certificate interacting packages (ssl, wincertstore, keyring) to do what you want is best. Alternatively, we do include a stripped-down version of PyWin32 which includes just the security APIs (ntsecuritycon, sspi, and win32security) that can be imported with `import pywin32security` as a starting point. Those are API wrappers around the underlying Win32 APIs that should provide what you need, though it may be somewhat challenging to work with them since they are low level.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 04:21:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1200681#M134</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2022-08-09T04:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch client certificate from Windows cert store using arcpy</title>
      <link>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1210641#M140</link>
      <description>&lt;P&gt;Yep personal certs from "MY", e.g.&amp;nbsp;to search for cert by subject or issuer CN&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import ssl
from cryptography.hazmat.backends import default_backend  # cryptography &amp;lt; 3.1 https://cryptography.io/en/latest/faq/?highlight=backend#what-happened-to-the-backend-argument
from cryptography.x509.oid import NameOID
from cryptography import x509

def get_cert(subject=None, issuer=None, store="MY"):
    for cert, encoding, trust in ssl.enum_certificates(store):
        certificate = x509.load_der_x509_certificate(cert, backend=default_backend())   # cryptography &amp;lt; 3.1 
        # certificate = x509.load_der_x509_certificate(cert)   # cryptography &amp;gt;= 3.1 

        if subject is not None and subject == certificate.subject.get_attributes_for_oid(NameOID.COMMON_NAME)[0].value:
            return certificate

        elif issuer is not None and issuer == certificate.issuer.get_attributes_for_oid(NameOID.COMMON_NAME)[0].value:
            return certificate&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 04:10:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1210641#M140</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-09-08T04:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch client certificate from Windows cert store using arcpy - Status changed to: Closed</title>
      <link>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1210920#M141</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/171761"&gt;@EricEagle&lt;/a&gt;&amp;nbsp;thanks for your idea on this. I believe that the solution proposed by&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10780"&gt;@Luke_Pinner&lt;/a&gt;&amp;nbsp;is a good one, and relies on existing components we provide in our stack without Esri trying to maintain something that we don't directly use nor expect to deliver to customers at this time. If certificate handling becomes part of the product, exposing this through Python would definitely be a valuable addition.&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Shaun&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 18:56:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1210920#M141</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2022-09-08T18:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch client certificate from Windows cert store using arcpy</title>
      <link>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1535336#M366</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10780"&gt;@Luke_Pinner&lt;/a&gt;&amp;nbsp;I'm the dumb kid. Can you provide an example of how the returned certificate would then be used in a requests GET request?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 23:28:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/fetch-client-certificate-from-windows-cert-store/idc-p/1535336#M366</guid>
      <dc:creator>DougZietz1</dc:creator>
      <dc:date>2024-09-04T23:28:39Z</dc:date>
    </item>
  </channel>
</rss>

