Skip to content

[uAMQP] https proxy support (proxy + tlsio) in C module #17972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yunhaoling opened this issue Apr 12, 2021 · 4 comments
Closed

[uAMQP] https proxy support (proxy + tlsio) in C module #17972

yunhaoling opened this issue Apr 12, 2021 · 4 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. Event Hubs Messaging Messaging crew P0 Service Bus uAMQP
Milestone

Comments

@yunhaoling
Copy link
Contributor

yunhaoling commented Apr 12, 2021

This is spawned from the issue: #16304 to better track the working progress.

tasks:

proxy tool:

  • proxy.py only supports proxy server certificate, it doesn't support client authentication
  • would need nginx/squid proxy server for mutual authentication

progress made (tested with proxy.py):

  • allowing to tlsio to use http proxy io as the underlying io
  • allowing to set http proxy io trustedCertificate/x509certificate/x509privateKey)
  • http proxy io could establish the tunnel to the host (HTTP CONNECT returns response code 200) with proxy server trustedCertificates (no x509certificate and x509privateKey)
@yunhaoling yunhaoling added P0 Service Bus Event Hubs Client This issue points to a problem in the data-plane of the library. uAMQP labels Apr 12, 2021
@yunhaoling yunhaoling added this to the [2021] May milestone Apr 12, 2021
@yunhaoling yunhaoling self-assigned this Apr 12, 2021
@lmazuel lmazuel added the Messaging Messaging crew label Apr 12, 2021
@yunhaoling
Copy link
Contributor Author

yunhaoling commented Apr 23, 2021

have a workable PR out: Azure/azure-uamqp-python#232

api shape would be

# proxy host name
proxy_hostname = "<host_name>"
# proxy port
proxy_port = 443
# proxy server certificate, a single file path
proxy_verify = r"<server_cert.pem>"
# client side certificate and private key, a tuple of both files’ paths
proxy_cert = (r"<client_cert.pem", r"<client_private_key.pem>")


HTTP_PROXY = {
    'proxy_hostname': proxy_hostname,
    'proxy_port': proxy_port,
    "proxy_verify": proxy_verify,
    "proxy_cert": proxy_cert
}

producer_client = EventHubProducerClient.from_connection_string(
    conn_str=CONNECTION_STR,
    eventhub_name=EVENTHUB_NAME,
    http_proxy=HTTP_PROXY
)

consumer_client = EventHubConsumerClient.from_connection_string(
    conn_str=CONNECTION_STR,
    consumer_group='$Default',
    eventhub_name=EVENTHUB_NAME,
    http_proxy=HTTP_PROXY,
    logging_enable=True
)

to set up a proxy with e2e encryption between client and the proxy server, check the commit here:
yunhaoling/proxy.py@7c7b561
(I use the open source project proxy.py and change some code to enable client side validation)

@yunhaoling
Copy link
Contributor Author

yunhaoling commented Apr 26, 2021

prototype is available here: https://github.com/yunhaoling/uamqp-tls-proxy-prototype

@yunhaoling
Copy link
Contributor Author

yunhaoling commented Apr 28, 2021

API in requests:

https://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification
https://docs.python-requests.org/en/latest/user/advanced/#client-side-certificates

source code: https://github.com/psf/requests/blob/master/requests/api.py#L16-L47
certificates related api shape:

'''
    :param verify: (optional) Either a boolean, in which case it controls whether we verify
            the server's TLS certificate, or a string, in which case it must be a path
            to a CA bundle to use. Defaults to ``True``.
    :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
'''
requests.get('https://kennethreitz.org', verify='/path/to/certfile', cert=('/path/client.cert', '/path/client.key'))

@yunhaoling
Copy link
Contributor Author

uamqp PR out for c module update: Azure/azure-uamqp-python#232

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. Event Hubs Messaging Messaging crew P0 Service Bus uAMQP
Projects
None yet
Development

No branches or pull requests

2 participants