prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [PORT] [Certificate Authentication] Expose sendX5c parameter
  > Port this change from botbuilder-dotnet/master branch:
  https://github.com/microsoft/botbuilder-dotnet/pull/3741
  
  This parameter enables application developers to achieve easy certificates roll-over in Azure AD: setting this parameter to true will send the public certificate to Azure AD along with the token request, so that Azure AD can use it to validate the subject name based on a trusted issuer policy. This saves the application admin from the need to explicitly manage the certificate rollover (either via portal or powershell/CLI operation)
  
  
  # Changed projects
  * Microsoft.Bot.Connector
  
  [R9,authentication]
  
  
  
  
  </issue>
  <code>
  [start of libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py]
  1 # Copyright (c) Microsoft Corporation. All rights reserved.
  2 # Licensed under the MIT License.
  3 
  4 from abc import ABC
  5 
  6 from msal import ConfidentialClientApplication
  7 
  8 from .app_credentials import AppCredentials
  9 
  10 
  11 class CertificateAppCredentials(AppCredentials, ABC):
  12     """
  13     AppCredentials implementation using a certificate.
  14 
  15     See:
  16     https://github.com/AzureAD/microsoft-authentication-library-for-python/wiki/Client-Credentials#client-credentials-with-certificate
  17     """
  18 
  19     def __init__(
  20         self,
  21         app_id: str,
  22         certificate_thumbprint: str,
  23         certificate_private_key: str,
  24         channel_auth_tenant: str = None,
  25         oauth_scope: str = None,
  26     ):
  27         # super will set proper scope and endpoint.
  28         super().__init__(
  29             app_id=app_id,
  30             channel_auth_tenant=channel_auth_tenant,
  31             oauth_scope=oauth_scope,
  32         )
  33 
  34         self.scopes = [self.oauth_scope]
  35         self.app = None
  36         self.certificate_thumbprint = certificate_thumbprint
  37         self.certificate_private_key = certificate_private_key
  38 
  39     def get_access_token(self, force_refresh: bool = False) -> str:
  40         """
  41         Implementation of AppCredentials.get_token.
  42         :return: The access token for the given certificate.
  43         """
  44 
  45         # Firstly, looks up a token from cache
  46         # Since we are looking for token for the current app, NOT for an end user,
  47         # notice we give account parameter as None.
  48         auth_token = self.__get_msal_app().acquire_token_silent(
  49             self.scopes, account=None
  50         )
  51         if not auth_token:
  52             # No suitable token exists in cache. Let's get a new one from AAD.
  53             auth_token = self.__get_msal_app().acquire_token_for_client(
  54                 scopes=self.scopes
  55             )
  56         return auth_token["access_token"]
  57 
  58     def __get_msal_app(self):
  59         if not self.app:
  60             self.app = ConfidentialClientApplication(
  61                 client_id=self.microsoft_app_id,
  62                 authority=self.oauth_endpoint,
  63                 client_credential={
  64                     "thumbprint": self.certificate_thumbprint,
  65                     "private_key": self.certificate_private_key,
  66                 },
  67             )
  68 
  69         return self.app
  70
  [end of libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py]
  [start of libraries/botframework-connector/setup.py]
  1 # Copyright (c) Microsoft Corporation. All rights reserved.
  2 # Licensed under the MIT License.
  3 import os
  4 from setuptools import setup
  5 
  6 NAME = "botframework-connector"
  7 VERSION = os.environ["packageVersion"] if "packageVersion" in os.environ else "4.7.1"
  8 REQUIRES = [
  9     "msrest==0.6.10",
  10     "requests==2.22.0",
  11     "cryptography==2.8.0",
  12     "PyJWT==1.5.3",
  13     "botbuilder-schema>=4.7.1",
  14     "adal==1.2.1",
  15     "msal==1.1.0",
  16 ]
  17 
  18 root = os.path.abspath(os.path.dirname(__file__))
  19 
  20 with open(os.path.join(root, "README.rst"), encoding="utf-8") as f:
  21     long_description = f.read()
  22 
  23 setup(
  24     name=NAME,
  25     version=VERSION,
  26     description="Microsoft Bot Framework Bot Builder SDK for Python.",
  27     author="Microsoft",
  28     url="https://www.github.com/Microsoft/botbuilder-python",
  29     keywords=["BotFrameworkConnector", "bots", "ai", "botframework", "botbuilder"],
  30     install_requires=REQUIRES,
  31     packages=[
  32         "botframework.connector",
  33         "botframework.connector.auth",
  34         "botframework.connector.async_mixin",
  35         "botframework.connector.operations",
  36         "botframework.connector.models",
  37         "botframework.connector.aio",
  38         "botframework.connector.aio.operations_async",
  39         "botframework.connector.teams",
  40         "botframework.connector.teams.operations",
  41         "botframework.connector.token_api",
  42         "botframework.connector.token_api.aio",
  43         "botframework.connector.token_api.models",
  44         "botframework.connector.token_api.operations",
  45     ],
  46     include_package_data=True,
  47     long_description=long_description,
  48     long_description_content_type="text/x-rst",
  49     license="MIT",
  50     classifiers=[
  51         "Programming Language :: Python :: 3.7",
  52         "Intended Audience :: Developers",
  53         "License :: OSI Approved :: MIT License",
  54         "Operating System :: OS Independent",
  55         "Development Status :: 5 - Production/Stable",
  56         "Topic :: Scientific/Engineering :: Artificial Intelligence",
  57     ],
  58 )
  59
  [end of libraries/botframework-connector/setup.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py b/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py
  --- a/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py
  +++ b/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py
  @@ -23,7 +23,20 @@
           certificate_private_key: str,
           channel_auth_tenant: str = None,
           oauth_scope: str = None,
  +        certificate_public: str = None,
       ):
  +        """
  +        AppCredentials implementation using a certificate.
  +
  +        :param app_id:
  +        :param certificate_thumbprint:
  +        :param certificate_private_key:
  +        :param channel_auth_tenant:
  +        :param oauth_scope:
  +        :param certificate_public: public_certificate (optional) is public key certificate which will be sent
  +        through ‘x5c’ JWT header only for subject name and issuer authentication to support cert auto rolls.
  +        """
  +
           # super will set proper scope and endpoint.
           super().__init__(
               app_id=app_id,
  @@ -35,6 +48,7 @@
           self.app = None
           self.certificate_thumbprint = certificate_thumbprint
           self.certificate_private_key = certificate_private_key
  +        self.certificate_public = certificate_public
   
       def get_access_token(self, force_refresh: bool = False) -> str:
           """
  @@ -63,6 +77,9 @@
                   client_credential={
                       "thumbprint": self.certificate_thumbprint,
                       "private_key": self.certificate_private_key,
  +                    "public_certificate": self.certificate_public
  +                    if self.certificate_public
  +                    else None,
                   },
               )
   
  diff --git a/libraries/botframework-connector/setup.py b/libraries/botframework-connector/setup.py
  --- a/libraries/botframework-connector/setup.py
  +++ b/libraries/botframework-connector/setup.py
  @@ -12,7 +12,7 @@
       "PyJWT==1.5.3",
       "botbuilder-schema>=4.7.1",
       "adal==1.2.1",
  -    "msal==1.1.0",
  +    "msal==1.2.0",
   ]
   
   root = os.path.abspath(os.path.dirname(__file__))
  
verification_info: {"golden_diff": "diff --git a/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py b/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py\n--- a/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py\n+++ b/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py\n@@ -23,7 +23,20 @@\n         certificate_private_key: str,\r\n         channel_auth_tenant: str = None,\r\n         oauth_scope: str = None,\r\n+        certificate_public: str = None,\r\n     ):\r\n+        \"\"\"\r\n+        AppCredentials implementation using a certificate.\r\n+\r\n+        :param app_id:\r\n+        :param certificate_thumbprint:\r\n+        :param certificate_private_key:\r\n+        :param channel_auth_tenant:\r\n+        :param oauth_scope:\r\n+        :param certificate_public: public_certificate (optional) is public key certificate which will be sent\r\n+        through \u2018x5c\u2019 JWT header only for subject name and issuer authentication to support cert auto rolls.\r\n+        \"\"\"\r\n+\r\n         # super will set proper scope and endpoint.\r\n         super().__init__(\r\n             app_id=app_id,\r\n@@ -35,6 +48,7 @@\n         self.app = None\r\n         self.certificate_thumbprint = certificate_thumbprint\r\n         self.certificate_private_key = certificate_private_key\r\n+        self.certificate_public = certificate_public\r\n \r\n     def get_access_token(self, force_refresh: bool = False) -> str:\r\n         \"\"\"\r\n@@ -63,6 +77,9 @@\n                 client_credential={\r\n                     \"thumbprint\": self.certificate_thumbprint,\r\n                     \"private_key\": self.certificate_private_key,\r\n+                    \"public_certificate\": self.certificate_public\r\n+                    if self.certificate_public\r\n+                    else None,\r\n                 },\r\n             )\r\n \r\ndiff --git a/libraries/botframework-connector/setup.py b/libraries/botframework-connector/setup.py\n--- a/libraries/botframework-connector/setup.py\n+++ b/libraries/botframework-connector/setup.py\n@@ -12,7 +12,7 @@\n     \"PyJWT==1.5.3\",\n     \"botbuilder-schema>=4.7.1\",\n     \"adal==1.2.1\",\n-    \"msal==1.1.0\",\n+    \"msal==1.2.0\",\n ]\n \n root = os.path.abspath(os.path.dirname(__file__))\n", "issue": "[PORT] [Certificate Authentication] Expose sendX5c parameter\n> Port this change from botbuilder-dotnet/master branch:\nhttps://github.com/microsoft/botbuilder-dotnet/pull/3741\n\nThis parameter enables application developers to achieve easy certificates roll-over in Azure AD: setting this parameter to true will send the public certificate to Azure AD along with the token request, so that Azure AD can use it to validate the subject name based on a trusted issuer policy. This saves the application admin from the need to explicitly manage the certificate rollover (either via portal or powershell/CLI operation)\n\n\r\n# Changed projects\r\n* Microsoft.Bot.Connector\r\n\r\n[R9,authentication]\r\n\r\n\n\n", "before_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\r\n# Licensed under the MIT License.\r\n\r\nfrom abc import ABC\r\n\r\nfrom msal import ConfidentialClientApplication\r\n\r\nfrom .app_credentials import AppCredentials\r\n\r\n\r\nclass CertificateAppCredentials(AppCredentials, ABC):\r\n    \"\"\"\r\n    AppCredentials implementation using a certificate.\r\n\r\n    See:\r\n    https://github.com/AzureAD/microsoft-authentication-library-for-python/wiki/Client-Credentials#client-credentials-with-certificate\r\n    \"\"\"\r\n\r\n    def __init__(\r\n        self,\r\n        app_id: str,\r\n        certificate_thumbprint: str,\r\n        certificate_private_key: str,\r\n        channel_auth_tenant: str = None,\r\n        oauth_scope: str = None,\r\n    ):\r\n        # super will set proper scope and endpoint.\r\n        super().__init__(\r\n            app_id=app_id,\r\n            channel_auth_tenant=channel_auth_tenant,\r\n            oauth_scope=oauth_scope,\r\n        )\r\n\r\n        self.scopes = [self.oauth_scope]\r\n        self.app = None\r\n        self.certificate_thumbprint = certificate_thumbprint\r\n        self.certificate_private_key = certificate_private_key\r\n\r\n    def get_access_token(self, force_refresh: bool = False) -> str:\r\n        \"\"\"\r\n        Implementation of AppCredentials.get_token.\r\n        :return: The access token for the given certificate.\r\n        \"\"\"\r\n\r\n        # Firstly, looks up a token from cache\r\n        # Since we are looking for token for the current app, NOT for an end user,\r\n        # notice we give account parameter as None.\r\n        auth_token = self.__get_msal_app().acquire_token_silent(\r\n            self.scopes, account=None\r\n        )\r\n        if not auth_token:\r\n            # No suitable token exists in cache. Let's get a new one from AAD.\r\n            auth_token = self.__get_msal_app().acquire_token_for_client(\r\n                scopes=self.scopes\r\n            )\r\n        return auth_token[\"access_token\"]\r\n\r\n    def __get_msal_app(self):\r\n        if not self.app:\r\n            self.app = ConfidentialClientApplication(\r\n                client_id=self.microsoft_app_id,\r\n                authority=self.oauth_endpoint,\r\n                client_credential={\r\n                    \"thumbprint\": self.certificate_thumbprint,\r\n                    \"private_key\": self.certificate_private_key,\r\n                },\r\n            )\r\n\r\n        return self.app\r\n", "path": "libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py"}, {"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\nimport os\nfrom setuptools import setup\n\nNAME = \"botframework-connector\"\nVERSION = os.environ[\"packageVersion\"] if \"packageVersion\" in os.environ else \"4.7.1\"\nREQUIRES = [\n    \"msrest==0.6.10\",\n    \"requests==2.22.0\",\n    \"cryptography==2.8.0\",\n    \"PyJWT==1.5.3\",\n    \"botbuilder-schema>=4.7.1\",\n    \"adal==1.2.1\",\n    \"msal==1.1.0\",\n]\n\nroot = os.path.abspath(os.path.dirname(__file__))\n\nwith open(os.path.join(root, \"README.rst\"), encoding=\"utf-8\") as f:\n    long_description = f.read()\n\nsetup(\n    name=NAME,\n    version=VERSION,\n    description=\"Microsoft Bot Framework Bot Builder SDK for Python.\",\n    author=\"Microsoft\",\n    url=\"https://www.github.com/Microsoft/botbuilder-python\",\n    keywords=[\"BotFrameworkConnector\", \"bots\", \"ai\", \"botframework\", \"botbuilder\"],\n    install_requires=REQUIRES,\n    packages=[\n        \"botframework.connector\",\n        \"botframework.connector.auth\",\n        \"botframework.connector.async_mixin\",\n        \"botframework.connector.operations\",\n        \"botframework.connector.models\",\n        \"botframework.connector.aio\",\n        \"botframework.connector.aio.operations_async\",\n        \"botframework.connector.teams\",\n        \"botframework.connector.teams.operations\",\n        \"botframework.connector.token_api\",\n        \"botframework.connector.token_api.aio\",\n        \"botframework.connector.token_api.models\",\n        \"botframework.connector.token_api.operations\",\n    ],\n    include_package_data=True,\n    long_description=long_description,\n    long_description_content_type=\"text/x-rst\",\n    license=\"MIT\",\n    classifiers=[\n        \"Programming Language :: Python :: 3.7\",\n        \"Intended Audience :: Developers\",\n        \"License :: OSI Approved :: MIT License\",\n        \"Operating System :: OS Independent\",\n        \"Development Status :: 5 - Production/Stable\",\n        \"Topic :: Scientific/Engineering :: Artificial Intelligence\",\n    ],\n)\n", "path": "libraries/botframework-connector/setup.py"}]}