|
6 | 6 | import typing
|
7 | 7 | import textwrap
|
8 | 8 | import click
|
9 |
| -from six import text_type |
10 | 9 | from os.path import abspath, dirname, exists, isdir, join
|
11 | 10 | from functools import wraps
|
| 11 | + |
| 12 | +from rsconnect.certificates import read_certificate_file |
| 13 | + |
12 | 14 | from .environment import EnvironmentException
|
13 | 15 | from .exception import RSConnectException
|
14 | 16 | from .actions import (
|
@@ -129,7 +131,7 @@ def server_args(func):
|
129 | 131 | "--cacert",
|
130 | 132 | "-c",
|
131 | 133 | envvar="CONNECT_CA_CERTIFICATE",
|
132 |
| - type=click.File(), |
| 134 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
133 | 135 | help="The path to trusted TLS CA certificates.",
|
134 | 136 | )
|
135 | 137 | @click.option("--verbose", "-v", is_flag=True, help="Print detailed messages.")
|
@@ -269,7 +271,7 @@ def _test_server_and_api(server, api_key, insecure, ca_cert):
|
269 | 271 | :return: a tuple containing an appropriate ConnectServer object and the username
|
270 | 272 | of the user the API key represents (or None, if no key was provided).
|
271 | 273 | """
|
272 |
| - ca_data = ca_cert and text_type(ca_cert.read()) |
| 274 | + ca_data = ca_cert and ca_cert.read() |
273 | 275 | me = None
|
274 | 276 |
|
275 | 277 | with cli_feedback("Checking %s" % server):
|
@@ -312,7 +314,7 @@ def _test_rstudio_creds(server: api.PositServer):
|
312 | 314 | "--cacert",
|
313 | 315 | "-c",
|
314 | 316 | envvar="CONNECT_CA_CERTIFICATE",
|
315 |
| - type=click.File(), |
| 317 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
316 | 318 | help="The path to trusted TLS CA certificates.",
|
317 | 319 | )
|
318 | 320 | @click.option(
|
@@ -344,7 +346,10 @@ def bootstrap(
|
344 | 346 | logger.debug("Generated JWT:\n" + bootstrap_token)
|
345 | 347 |
|
346 | 348 | logger.debug("Insecure: " + str(insecure))
|
347 |
| - ca_data = cacert and text_type(cacert.read()) |
| 349 | + |
| 350 | + ca_data = None |
| 351 | + if cacert: |
| 352 | + ca_data = read_certificate_file(cacert) |
348 | 353 |
|
349 | 354 | with cli_feedback("", stderr=True):
|
350 | 355 | connect_server = RSConnectServer(
|
@@ -398,7 +403,7 @@ def bootstrap(
|
398 | 403 | "--cacert",
|
399 | 404 | "-c",
|
400 | 405 | envvar="CONNECT_CA_CERTIFICATE",
|
401 |
| - type=click.File(), |
| 406 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
402 | 407 | help="The path to trusted TLS CA certificates.",
|
403 | 408 | )
|
404 | 409 | @click.option("--verbose", "-v", is_flag=True, help="Print detailed messages.")
|
@@ -1674,7 +1679,7 @@ def content():
|
1674 | 1679 | "--cacert",
|
1675 | 1680 | "-c",
|
1676 | 1681 | envvar="CONNECT_CA_CERTIFICATE",
|
1677 |
| - type=click.File(), |
| 1682 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
1678 | 1683 | help="The path to trusted TLS CA certificates.",
|
1679 | 1684 | )
|
1680 | 1685 | @click.option(
|
@@ -1768,7 +1773,7 @@ def content_search(
|
1768 | 1773 | "--cacert",
|
1769 | 1774 | "-c",
|
1770 | 1775 | envvar="CONNECT_CA_CERTIFICATE",
|
1771 |
| - type=click.File(), |
| 1776 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
1772 | 1777 | help="The path to trusted TLS CA certificates.",
|
1773 | 1778 | )
|
1774 | 1779 | @click.option(
|
@@ -1819,7 +1824,7 @@ def content_describe(name, server, api_key, insecure, cacert, guid, verbose):
|
1819 | 1824 | "--cacert",
|
1820 | 1825 | "-c",
|
1821 | 1826 | envvar="CONNECT_CA_CERTIFICATE",
|
1822 |
| - type=click.File(), |
| 1827 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
1823 | 1828 | help="The path to trusted TLS CA certificates.",
|
1824 | 1829 | )
|
1825 | 1830 | @click.option(
|
@@ -1888,7 +1893,7 @@ def build():
|
1888 | 1893 | "--cacert",
|
1889 | 1894 | "-c",
|
1890 | 1895 | envvar="CONNECT_CA_CERTIFICATE",
|
1891 |
| - type=click.File(), |
| 1896 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
1892 | 1897 | help="The path to trusted TLS CA certificates.",
|
1893 | 1898 | )
|
1894 | 1899 | @click.option(
|
@@ -1942,7 +1947,7 @@ def add_content_build(name, server, api_key, insecure, cacert, guid, verbose):
|
1942 | 1947 | "--cacert",
|
1943 | 1948 | "-c",
|
1944 | 1949 | envvar="CONNECT_CA_CERTIFICATE",
|
1945 |
| - type=click.File(), |
| 1950 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
1946 | 1951 | help="The path to trusted TLS CA certificates.",
|
1947 | 1952 | )
|
1948 | 1953 | @click.option(
|
@@ -2005,7 +2010,7 @@ def remove_content_build(name, server, api_key, insecure, cacert, guid, all, pur
|
2005 | 2010 | "--cacert",
|
2006 | 2011 | "-c",
|
2007 | 2012 | envvar="CONNECT_CA_CERTIFICATE",
|
2008 |
| - type=click.File(), |
| 2013 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
2009 | 2014 | help="The path to trusted TLS CA certificates.",
|
2010 | 2015 | )
|
2011 | 2016 | @click.option("--status", type=click.Choice(BuildStatus._all), help="Filter results by status of the build operation.")
|
@@ -2053,7 +2058,7 @@ def list_content_build(name, server, api_key, insecure, cacert, status, guid, ve
|
2053 | 2058 | "--cacert",
|
2054 | 2059 | "-c",
|
2055 | 2060 | envvar="CONNECT_CA_CERTIFICATE",
|
2056 |
| - type=click.File(), |
| 2061 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
2057 | 2062 | help="The path to trusted TLS CA certificates.",
|
2058 | 2063 | )
|
2059 | 2064 | @click.option(
|
@@ -2104,7 +2109,7 @@ def get_build_history(name, server, api_key, insecure, cacert, guid, verbose):
|
2104 | 2109 | "--cacert",
|
2105 | 2110 | "-c",
|
2106 | 2111 | envvar="CONNECT_CA_CERTIFICATE",
|
2107 |
| - type=click.File(), |
| 2112 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
2108 | 2113 | help="The path to trusted TLS CA certificates.",
|
2109 | 2114 | )
|
2110 | 2115 | @click.option(
|
@@ -2167,7 +2172,7 @@ def get_build_logs(name, server, api_key, insecure, cacert, guid, task_id, forma
|
2167 | 2172 | "--cacert",
|
2168 | 2173 | "-c",
|
2169 | 2174 | envvar="CONNECT_CA_CERTIFICATE",
|
2170 |
| - type=click.File(), |
| 2175 | + type=click.Path(exists=True, file_okay=True, dir_okay=False), |
2171 | 2176 | help="The path to trusted TLS CA certificates.",
|
2172 | 2177 | )
|
2173 | 2178 | @click.option(
|
|
0 commit comments