We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add ssl extra arguments to postgres hook
This enables one to specify items such as ssl certificate paths in the extra field of a postgres connection object. Rather than simply pass-through everything from the extra field, I followed the existing code pattern of selecting for specific arguments, as demonstrated in other hooks. I tested this in Python 2.7.6 and Python 2.7.10.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `airflow/hooks/postgres_hook.py`
Content:
```
1 import psycopg2
2 
3 from airflow.hooks.dbapi_hook import DbApiHook
4 
5 
6 class PostgresHook(DbApiHook):
7     '''
8     Interact with Postgres.
9     '''
10     conn_name_attr = 'postgres_conn_id'
11     default_conn_name = 'postgres_default'
12     supports_autocommit = True
13 
14     def get_conn(self):
15         conn = self.get_connection(self.postgres_conn_id)
16         return psycopg2.connect(
17             host=conn.host,
18             user=conn.login,
19             password=conn.password,
20             dbname=conn.schema,
21             port=conn.port)
22
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/airflow/hooks/postgres_hook.py b/airflow/hooks/postgres_hook.py
--- a/airflow/hooks/postgres_hook.py
+++ b/airflow/hooks/postgres_hook.py
@@ -6,6 +6,8 @@
 class PostgresHook(DbApiHook):
     '''
     Interact with Postgres.
+    You can specify ssl parameters in the extra field of your connection
+    as ``{"sslmode": "require", "sslcert": "/path/to/cert.pem", etc}``.
     '''
     conn_name_attr = 'postgres_conn_id'
     default_conn_name = 'postgres_default'
@@ -13,9 +15,14 @@
 
     def get_conn(self):
         conn = self.get_connection(self.postgres_conn_id)
-        return psycopg2.connect(
+        conn_args = dict(
             host=conn.host,
             user=conn.login,
             password=conn.password,
             dbname=conn.schema,
             port=conn.port)
+        # check for ssl parameters in conn.extra
+        for arg_name, arg_val in conn.extra_dejson.items():
+            if arg_name in ['sslmode', 'sslcert', 'sslkey', 'sslrootcert', 'sslcrl']:
+                conn_args[arg_name] = arg_val
+        return psycopg2.connect(**conn_args)

{"golden_diff": "diff --git a/airflow/hooks/postgres_hook.py b/airflow/hooks/postgres_hook.py\n--- a/airflow/hooks/postgres_hook.py\n+++ b/airflow/hooks/postgres_hook.py\n@@ -6,6 +6,8 @@\n class PostgresHook(DbApiHook):\n     '''\n     Interact with Postgres.\n+    You can specify ssl parameters in the extra field of your connection\n+    as ``{\"sslmode\": \"require\", \"sslcert\": \"/path/to/cert.pem\", etc}``.\n     '''\n     conn_name_attr = 'postgres_conn_id'\n     default_conn_name = 'postgres_default'\n@@ -13,9 +15,14 @@\n \n     def get_conn(self):\n         conn = self.get_connection(self.postgres_conn_id)\n-        return psycopg2.connect(\n+        conn_args = dict(\n             host=conn.host,\n             user=conn.login,\n             password=conn.password,\n             dbname=conn.schema,\n             port=conn.port)\n+        # check for ssl parameters in conn.extra\n+        for arg_name, arg_val in conn.extra_dejson.items():\n+            if arg_name in ['sslmode', 'sslcert', 'sslkey', 'sslrootcert', 'sslcrl']:\n+                conn_args[arg_name] = arg_val\n+        return psycopg2.connect(**conn_args)\n", "issue": "Add ssl extra arguments to postgres hook\nThis enables one to specify items such as ssl certificate paths in the extra field of a postgres connection object. Rather than simply pass-through everything from the extra field, I followed the existing code pattern of selecting for specific arguments, as demonstrated in other hooks. I tested this in Python 2.7.6 and Python 2.7.10.\n\n", "before_files": [{"content": "import psycopg2\n\nfrom airflow.hooks.dbapi_hook import DbApiHook\n\n\nclass PostgresHook(DbApiHook):\n    '''\n    Interact with Postgres.\n    '''\n    conn_name_attr = 'postgres_conn_id'\n    default_conn_name = 'postgres_default'\n    supports_autocommit = True\n\n    def get_conn(self):\n        conn = self.get_connection(self.postgres_conn_id)\n        return psycopg2.connect(\n            host=conn.host,\n            user=conn.login,\n            password=conn.password,\n            dbname=conn.schema,\n            port=conn.port)\n", "path": "airflow/hooks/postgres_hook.py"}], "after_files": [{"content": "import psycopg2\n\nfrom airflow.hooks.dbapi_hook import DbApiHook\n\n\nclass PostgresHook(DbApiHook):\n    '''\n    Interact with Postgres.\n    You can specify ssl parameters in the extra field of your connection\n    as ``{\"sslmode\": \"require\", \"sslcert\": \"/path/to/cert.pem\", etc}``.\n    '''\n    conn_name_attr = 'postgres_conn_id'\n    default_conn_name = 'postgres_default'\n    supports_autocommit = True\n\n    def get_conn(self):\n        conn = self.get_connection(self.postgres_conn_id)\n        conn_args = dict(\n            host=conn.host,\n            user=conn.login,\n            password=conn.password,\n            dbname=conn.schema,\n            port=conn.port)\n        # check for ssl parameters in conn.extra\n        for arg_name, arg_val in conn.extra_dejson.items():\n            if arg_name in ['sslmode', 'sslcert', 'sslkey', 'sslrootcert', 'sslcrl']:\n                conn_args[arg_name] = arg_val\n        return psycopg2.connect(**conn_args)\n", "path": "airflow/hooks/postgres_hook.py"}]}