kepconfig.ua_gateway.certificates

certificates exposes an API to allow read access to UA Gateway plug-in instance certificate objects within the Kepware Configuration API

 1# -------------------------------------------------------------------------
 2# Copyright (c) 2023 PTC Inc. and/or all its affiliates. All rights reserved.
 3# See License.txt in the project root for
 4# license information.
 5# --------------------------------------------------------------------------
 6
 7r"""`certificates` exposes an API to allow read access to 
 8UA Gateway plug-in instance certificate objects within the Kepware Configuration API
 9"""
10
11from ..connection import server
12from ..error import KepHTTPError
13from ..ua_gateway.common import _INTER_TYPE, _create_url_cert, INSTANCE_CERTIFICATE
14
15import warnings
16from ..helpers.deprecation_utils import _deprecated
17
18
19# Enable DeprecationWarnings to be visible
20warnings.simplefilter('always', DeprecationWarning)
21
22@_deprecated("This function is deprecated and will be removed in a future release. Use `get_instance_certificate()` in UAG client or server module instead.")
23def get_instance_certificate(server: server) -> dict:
24    '''
25    DEPRECATED: This function is deprecated and will be removed in a future release. Use `get_instance_certificate()` 
26    in UAG client or server module instead for Kepware 6.18+.
27
28    Returns the properties of the UAG instance certificate object in the UAG certificate store. 
29    These are UAG instance certificates that are used by UAG for trust purposes in the UA security model.
30    
31    :param server: instance of the `server` class
32    
33    :return: Dict of properties for the certificate requested
34
35    :raises KepHTTPError: If urllib provides an HTTPError
36    :raises KepURLError: If urllib provides an URLError
37    '''
38    r = server._config_get(server.url + _create_url_cert(_INTER_TYPE.CERTS, INSTANCE_CERTIFICATE))
39    return r.payload
40
41@_deprecated("This function is deprecated and will be removed in a future release. Use `TBD` instead.")
42def reissue_self_signed_instance_certificate(server: server) -> bool:
43    '''
44    DEPRECATED: This function is deprecated and will be removed in a future release. Use `get_instance_certificate()` 
45    in UAG client or server module instead for Kepware 6.18+.
46    
47    Deletes and reissues a self-signed UAG instance certificate object in the UAG certificate store. 
48    This is the UAG instance certificate that are used by UAG for trust purposes in the UA security model.
49    
50    :param server: instance of the `server` class
51    
52    :return: True - If a "HTTP 200 - OK" is received from Kepware server
53
54    :raises KepHTTPError: If urllib provides an HTTPError
55    :raises KepURLError: If urllib provides an URLError
56    '''
57    r = server._config_del(server.url + _create_url_cert(_INTER_TYPE.CERTS, INSTANCE_CERTIFICATE))
58    if r.code == 200: return True 
59    else: 
60        raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)
def get_instance_certificate(server: kepconfig.connection.server) -> dict:
23@_deprecated("This function is deprecated and will be removed in a future release. Use `get_instance_certificate()` in UAG client or server module instead.")
24def get_instance_certificate(server: server) -> dict:
25    '''
26    DEPRECATED: This function is deprecated and will be removed in a future release. Use `get_instance_certificate()` 
27    in UAG client or server module instead for Kepware 6.18+.
28
29    Returns the properties of the UAG instance certificate object in the UAG certificate store. 
30    These are UAG instance certificates that are used by UAG for trust purposes in the UA security model.
31    
32    :param server: instance of the `server` class
33    
34    :return: Dict of properties for the certificate requested
35
36    :raises KepHTTPError: If urllib provides an HTTPError
37    :raises KepURLError: If urllib provides an URLError
38    '''
39    r = server._config_get(server.url + _create_url_cert(_INTER_TYPE.CERTS, INSTANCE_CERTIFICATE))
40    return r.payload

DEPRECATED: This function is deprecated and will be removed in a future release. Use get_instance_certificate() in UAG client or server module instead for Kepware 6.18+.

Returns the properties of the UAG instance certificate object in the UAG certificate store. These are UAG instance certificates that are used by UAG for trust purposes in the UA security model.

Parameters
  • server: instance of the server class
Returns

Dict of properties for the certificate requested

Raises
  • KepHTTPError: If urllib provides an HTTPError
  • KepURLError: If urllib provides an URLError
def reissue_self_signed_instance_certificate(server: kepconfig.connection.server) -> bool:
42@_deprecated("This function is deprecated and will be removed in a future release. Use `TBD` instead.")
43def reissue_self_signed_instance_certificate(server: server) -> bool:
44    '''
45    DEPRECATED: This function is deprecated and will be removed in a future release. Use `get_instance_certificate()` 
46    in UAG client or server module instead for Kepware 6.18+.
47    
48    Deletes and reissues a self-signed UAG instance certificate object in the UAG certificate store. 
49    This is the UAG instance certificate that are used by UAG for trust purposes in the UA security model.
50    
51    :param server: instance of the `server` class
52    
53    :return: True - If a "HTTP 200 - OK" is received from Kepware server
54
55    :raises KepHTTPError: If urllib provides an HTTPError
56    :raises KepURLError: If urllib provides an URLError
57    '''
58    r = server._config_del(server.url + _create_url_cert(_INTER_TYPE.CERTS, INSTANCE_CERTIFICATE))
59    if r.code == 200: return True 
60    else: 
61        raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)

DEPRECATED: This function is deprecated and will be removed in a future release. Use get_instance_certificate() in UAG client or server module instead for Kepware 6.18+.

Deletes and reissues a self-signed UAG instance certificate object in the UAG certificate store. This is the UAG instance certificate that are used by UAG for trust purposes in the UA security model.

Parameters
  • server: instance of the server class
Returns

True - If a "HTTP 200 - OK" is received from Kepware server

Raises
  • KepHTTPError: If urllib provides an HTTPError
  • KepURLError: If urllib provides an URLError