[GH-ISSUE #1220] [Enhancement] Direct merge Proxyman certificate to python certs #1214

Closed
opened 2026-03-03 19:49:22 +03:00 by kerem · 14 comments
Owner

Originally created by @novitae on GitHub (May 3, 2022).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1220

Originally assigned to: @NghiaTranUIT on GitHub.

Hello,

I recently have few issues with my certs in python and Proxyman. I of course followed what is written here, but a lot of certificate bugs happened with other modules than requests.

httpx and aiohttp were making certsslverifyerror with the method written in the documentation. By replacing directly certifi certificate, when Proxyman was closed all (requests, httpx and aiohttp) were making certsslverifyerror.

I found a solution, and made this little script:

try:
    from certifi import where
except ModuleNotFoundError:
    exit('Please run "pip install certifi"')
from re import findall, match
from argparse import ArgumentParser

RE_CERT = r"-----BEGIN\ CERTIFICATE-----\n[A-Za-z0-9\/\+\n]{1,}-----END\ CERTIFICATE-----\n"

def read_certifi(certifi_path:str) -> str:
    """Returns the content of cacert.pem of certifi"""
    with open(certifi_path, "r") as read:
        certifi_content = read.read()
    return certifi_content

def merge_cert(certifi_path:str, content:str) -> None:
    """Adds the content of Proxyman certificate to cacert.pem"""
    with open(certifi_path, "a") as append:
        # Appends the proxyman cert with "# Proxyman Root Certificate" written over
        # so we can find it back with regex
        append.write(f"\n# Proxyman Root Certificate\n{content}\n")
    print("Proxyman certificate succesfully added.")

def remove_cert(certifi_path:str) -> None:
    """Removes the Proxyman certificate of the cacert.pem"""
    certifi_content = read_certifi(certifi_path=certifi_path)
    proxyman_lines = findall(
        r"\n#\ Proxyman\ Root\ Certificate\n" + RE_CERT,
        certifi_content
    ) # Finds back the content of the previously added proxyman cert with regex
    
    if not proxyman_lines:
        exit("Proxyman certificate have not been added to your python certificates yet.")
    
    new_certifi_content = certifi_content.replace(proxyman_lines[0], "")
    
    # while there's two breakline at the end, we remove the last one
    while new_certifi_content[-2:] == "\n\n":
        new_certifi_content = new_certifi_content[:-1]

    with open(certifi_path, "w") as write:
        write.write(new_certifi_content)
    print("Proxyman certificate removed succesfully.")

def read_proxyman_cert(path: str) -> str:
    """Reads and return in str the content of the input certificate"""
    try:
        with open(path, "r") as read:
            content = read.read()
    except FileNotFoundError:
        exit("Please make sure the path to the exported Proxyman certificate is the right one.")
    return content

def main() -> None:
    parser = ArgumentParser()
    parser.add_argument("action", choices=["add", "remove"], help="choose to add or remove the proxyman certificate from your python certificates")
    action = parser.parse_args().action

    certifi_path = where()
    if action == "add":
        print('Open Proxyman, go to "Certificate" -> "Export" -> "Root Certificate as PEM..." and save it somewhere.')
        proxyman_cert_path = input("Paste the path to the exported Certificate -> ")

        # Steps to verify if the cert is in great format and all to avoid
        # merging a shopping list or idk what to the certificates
        if len(proxyman_cert_path) < 4:
            exit("Invalid path.")
        if proxyman_cert_path[-4:] != ".pem":
            exit('The path must be pointing to a ".pem" certificate.')
        proxyman_cert_content = read_proxyman_cert(path=proxyman_cert_path)
        if not match(RE_CERT, proxyman_cert_content):
            exit(f'Invalid ".pem" file content (not matching re"{RE_CERT}").')

        # Checks if the certificate is already present in the certificate list
        if proxyman_cert_content in read_certifi(certifi_path=certifi_path):
            exit("This certificate is already present in certifi certificates.")

        # If it is all good, merge
        merge_cert(certifi_path=certifi_path, content=proxyman_cert_content)

    elif action == "remove":
        remove_cert(certifi_path=certifi_path)

if __name__ == "__main__":
    main()

It allows to add directly the content of Proxyman's .pem root ca to the certificates of certifi module of python. It is very simple to use, by making python file.py add (or) remove. add will ask the path to root certificate of Proxyman, and will merge it to certifi. remove will match the previous one added, and remove it from the file.

All is made to, if removed, don't keep additional breaklines, to be the cleanest as possible.

The traffic will be captured for all modules that needs to make requests, wether Proxyman is opened or closed. And if this method causes errors for other people, at least you just have to run python file.py remove.

Originally created by @novitae on GitHub (May 3, 2022). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1220 Originally assigned to: @NghiaTranUIT on GitHub. Hello, I recently have few issues with my certs in python and Proxyman. I of course followed what is written [here](https://docs.proxyman.io/debug-devices/python), but a lot of certificate bugs happened with other modules than requests. `httpx` and `aiohttp` were making `certsslverifyerror` with the method written in the documentation. By replacing directly `certifi` certificate, when Proxyman was closed all (`requests`, `httpx` and `aiohttp`) were making `certsslverifyerror`. I found a solution, and made this little script: ```python try: from certifi import where except ModuleNotFoundError: exit('Please run "pip install certifi"') from re import findall, match from argparse import ArgumentParser RE_CERT = r"-----BEGIN\ CERTIFICATE-----\n[A-Za-z0-9\/\+\n]{1,}-----END\ CERTIFICATE-----\n" def read_certifi(certifi_path:str) -> str: """Returns the content of cacert.pem of certifi""" with open(certifi_path, "r") as read: certifi_content = read.read() return certifi_content def merge_cert(certifi_path:str, content:str) -> None: """Adds the content of Proxyman certificate to cacert.pem""" with open(certifi_path, "a") as append: # Appends the proxyman cert with "# Proxyman Root Certificate" written over # so we can find it back with regex append.write(f"\n# Proxyman Root Certificate\n{content}\n") print("Proxyman certificate succesfully added.") def remove_cert(certifi_path:str) -> None: """Removes the Proxyman certificate of the cacert.pem""" certifi_content = read_certifi(certifi_path=certifi_path) proxyman_lines = findall( r"\n#\ Proxyman\ Root\ Certificate\n" + RE_CERT, certifi_content ) # Finds back the content of the previously added proxyman cert with regex if not proxyman_lines: exit("Proxyman certificate have not been added to your python certificates yet.") new_certifi_content = certifi_content.replace(proxyman_lines[0], "") # while there's two breakline at the end, we remove the last one while new_certifi_content[-2:] == "\n\n": new_certifi_content = new_certifi_content[:-1] with open(certifi_path, "w") as write: write.write(new_certifi_content) print("Proxyman certificate removed succesfully.") def read_proxyman_cert(path: str) -> str: """Reads and return in str the content of the input certificate""" try: with open(path, "r") as read: content = read.read() except FileNotFoundError: exit("Please make sure the path to the exported Proxyman certificate is the right one.") return content def main() -> None: parser = ArgumentParser() parser.add_argument("action", choices=["add", "remove"], help="choose to add or remove the proxyman certificate from your python certificates") action = parser.parse_args().action certifi_path = where() if action == "add": print('Open Proxyman, go to "Certificate" -> "Export" -> "Root Certificate as PEM..." and save it somewhere.') proxyman_cert_path = input("Paste the path to the exported Certificate -> ") # Steps to verify if the cert is in great format and all to avoid # merging a shopping list or idk what to the certificates if len(proxyman_cert_path) < 4: exit("Invalid path.") if proxyman_cert_path[-4:] != ".pem": exit('The path must be pointing to a ".pem" certificate.') proxyman_cert_content = read_proxyman_cert(path=proxyman_cert_path) if not match(RE_CERT, proxyman_cert_content): exit(f'Invalid ".pem" file content (not matching re"{RE_CERT}").') # Checks if the certificate is already present in the certificate list if proxyman_cert_content in read_certifi(certifi_path=certifi_path): exit("This certificate is already present in certifi certificates.") # If it is all good, merge merge_cert(certifi_path=certifi_path, content=proxyman_cert_content) elif action == "remove": remove_cert(certifi_path=certifi_path) if __name__ == "__main__": main() ``` It allows to add directly the content of Proxyman's .pem root ca to the certificates of `certifi` module of python. It is very simple to use, by making `python file.py add (or) remove`. `add` will ask the path to root certificate of Proxyman, and will merge it to certifi. `remove` will match the previous one added, and remove it from the file. All is made to, if removed, don't keep additional breaklines, to be the cleanest as possible. The traffic will be captured for all modules that needs to make requests, wether Proxyman is opened or closed. And if this method causes errors for other people, at least you just have to run `python file.py remove`.
kerem 2026-03-03 19:49:22 +03:00
  • closed this issue
  • added the
    Done
    label
Author
Owner

@NghiaTranUIT commented on GitHub (May 3, 2022):

Thanks for your hard work @novitae 🙌

I will add your script to our Python Doc, so others can manually run it on their machine.

I don't think that I should add your script to Proxyman (to automatically perform) because python2 is completely removed from macOS 12.3.1.

<!-- gh-comment-id:1116024464 --> @NghiaTranUIT commented on GitHub (May 3, 2022): Thanks for your hard work @novitae 🙌 I will add your script to our Python Doc, so others can manually run it on their machine. I don't think that I should add your script to Proxyman (to automatically perform) because python2 is completely removed from macOS 12.3.1.
Author
Owner

@novitae commented on GitHub (May 3, 2022):

I don't think that I should add your script to Proxyman (to automatically perform) because python2 is completely removed from macOS 12.3.1.

Anyway it is not python2-compatible so it's not a problem 😄

<!-- gh-comment-id:1116116158 --> @novitae commented on GitHub (May 3, 2022): > I don't think that I should add your script to Proxyman (to automatically perform) because python2 is completely removed from macOS 12.3.1. Anyway it is not python2-compatible so it's not a problem 😄
Author
Owner

@novitae commented on GitHub (May 3, 2022):

@NghiaTranUIT This script works well for what all what I tried, but I didn't tested all python capabilities with it. As an example, I got my first error due to this technique, I'm getting ssl error with pip package when Proxyman is opened and running with SSL Proxying list targeting python.

I must run pip install PACKAGE_NAME --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org to bypass this.

I don't know what you wanted to do in the documentation, but don't remove the previous written things because it seems that all methods have it strengths and its weakness. Just append mine if you want, but don't remove other methods.

<!-- gh-comment-id:1116135418 --> @novitae commented on GitHub (May 3, 2022): @NghiaTranUIT This script works well for what all what I tried, but I didn't tested all python capabilities with it. As an example, I got my first error due to this technique, I'm getting ssl error with `pip` package when Proxyman is opened and running with SSL Proxying list targeting python. I must run `pip install PACKAGE_NAME --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org` to bypass this. I don't know what you wanted to do in the documentation, but don't remove the previous written things because it seems that all methods have it strengths and its weakness. Just append mine if you want, but don't remove other methods.
Author
Owner

@azarouski commented on GitHub (Sep 8, 2022):

@novitae Big thanks for this script. When i used it I noticed that regex part it not fully matched with my certificate, so in result of my little research i found that in
...[A-Za-z0-9\/\+\n]{1,}...
you need to add = sign.
Result should look like
...[A-Za-z0-9\/\+\n=]{1,}...

<!-- gh-comment-id:1240680978 --> @azarouski commented on GitHub (Sep 8, 2022): @novitae Big thanks for this script. When i used it I noticed that regex part it not fully matched with my certificate, so in result of my little research i found that in `...[A-Za-z0-9\/\+\n]{1,}...` you need to add `=` sign. Result should look like `...[A-Za-z0-9\/\+\n=]{1,}...`
Author
Owner

@novitae commented on GitHub (Sep 16, 2022):

little update about this script, thanks to @azarouski

also added new path verification because the old one was trash

try:
    from certifi import where
except ModuleNotFoundError:
    exit('Please run "pip install certifi"')
from re import findall, match
from argparse import ArgumentParser

RE_CERT = r"-----BEGIN\ CERTIFICATE-----\n[A-Za-z0-9\/\+\n=]{1,}-----END\ CERTIFICATE-----\n"

def read_certifi(certifi_path:str) -> str:
    """Returns the content of cacert.pem of certifi"""
    with open(certifi_path, "r") as read:
        certifi_content = read.read()
    return certifi_content

def merge_cert(certifi_path:str, content:str) -> None:
    """Adds the content of Proxyman certificate to cacert.pem"""
    with open(certifi_path, "a") as append:
        # Appends the proxyman cert with "# Proxyman Root Certificate" written over
        # so we can find it back with regex
        append.write(f"\n# Proxyman Root Certificate\n{content}\n")
    print("Proxyman certificate succesfully added.")

def remove_cert(certifi_path:str) -> None:
    """Removes the Proxyman certificate of the cacert.pem"""
    certifi_content = read_certifi(certifi_path=certifi_path)
    proxyman_lines = findall(
        r"\n#\ Proxyman\ Root\ Certificate\n" + RE_CERT,
        certifi_content
    ) # Finds back the content of the previously added proxyman cert with regex
    
    if not proxyman_lines:
        exit("Proxyman certificate have not been added to your python certificates yet.")
    
    new_certifi_content = certifi_content.replace(proxyman_lines[0], "")
    
    # while there's two breakline at the end, we remove the last one
    while new_certifi_content[-2:] == "\n\n":
        new_certifi_content = new_certifi_content[:-1]

    with open(certifi_path, "w") as write:
        write.write(new_certifi_content)
    print("Proxyman certificate removed succesfully.")

def read_proxyman_cert(path: str) -> str:
    """Reads and return in str the content of the input certificate"""
    try:
        print(path)
        with open(path, "r") as read:
            content = read.read()
    except FileNotFoundError:
        exit("Please make sure the path to the exported Proxyman certificate is the right one.")
    return content

def main() -> None:
    parser = ArgumentParser()
    parser.add_argument("action", choices=["add", "remove"], help="choose to add or remove the proxyman certificate from your python certificates")
    action = parser.parse_args().action

    certifi_path = where()
    if action == "add":
        print('Open Proxyman, go to "Certificate" -> "Export" -> "Root Certificate as PEM..." and save it somewhere.')
        proxyman_cert_path = input("Paste the path to the exported Certificate -> ")

        # Steps to verify if the cert is in great format and all to avoid
        # merging a shopping list or idk what to the certificates
        if len(proxyman_cert_path) < 4:
            exit("Invalid path.")

        if proxyman_cert_path.endswith((".pem'", '.pem"')):
            proxyman_cert_path = proxyman_cert_path[1:-1]
        if not proxyman_cert_path.endswith(".pem"):
            exit('The path must be pointing to a ".pem" certificate.')
        proxyman_cert_content = read_proxyman_cert(path=proxyman_cert_path)
        if not match(RE_CERT, proxyman_cert_content):
            exit(f'Invalid ".pem" file content (not matching re"{RE_CERT}").')

        # Checks if the certificate is already present in the certificate list
        if proxyman_cert_content in read_certifi(certifi_path=certifi_path):
            exit("This certificate is already present in certifi certificates.")

        # If it is all good, merge
        merge_cert(certifi_path=certifi_path, content=proxyman_cert_content)

    elif action == "remove":
        remove_cert(certifi_path=certifi_path)

if __name__ == "__main__":
    main()
<!-- gh-comment-id:1249090359 --> @novitae commented on GitHub (Sep 16, 2022): little update about this script, thanks to @azarouski also added new path verification because the old one was trash ```python try: from certifi import where except ModuleNotFoundError: exit('Please run "pip install certifi"') from re import findall, match from argparse import ArgumentParser RE_CERT = r"-----BEGIN\ CERTIFICATE-----\n[A-Za-z0-9\/\+\n=]{1,}-----END\ CERTIFICATE-----\n" def read_certifi(certifi_path:str) -> str: """Returns the content of cacert.pem of certifi""" with open(certifi_path, "r") as read: certifi_content = read.read() return certifi_content def merge_cert(certifi_path:str, content:str) -> None: """Adds the content of Proxyman certificate to cacert.pem""" with open(certifi_path, "a") as append: # Appends the proxyman cert with "# Proxyman Root Certificate" written over # so we can find it back with regex append.write(f"\n# Proxyman Root Certificate\n{content}\n") print("Proxyman certificate succesfully added.") def remove_cert(certifi_path:str) -> None: """Removes the Proxyman certificate of the cacert.pem""" certifi_content = read_certifi(certifi_path=certifi_path) proxyman_lines = findall( r"\n#\ Proxyman\ Root\ Certificate\n" + RE_CERT, certifi_content ) # Finds back the content of the previously added proxyman cert with regex if not proxyman_lines: exit("Proxyman certificate have not been added to your python certificates yet.") new_certifi_content = certifi_content.replace(proxyman_lines[0], "") # while there's two breakline at the end, we remove the last one while new_certifi_content[-2:] == "\n\n": new_certifi_content = new_certifi_content[:-1] with open(certifi_path, "w") as write: write.write(new_certifi_content) print("Proxyman certificate removed succesfully.") def read_proxyman_cert(path: str) -> str: """Reads and return in str the content of the input certificate""" try: print(path) with open(path, "r") as read: content = read.read() except FileNotFoundError: exit("Please make sure the path to the exported Proxyman certificate is the right one.") return content def main() -> None: parser = ArgumentParser() parser.add_argument("action", choices=["add", "remove"], help="choose to add or remove the proxyman certificate from your python certificates") action = parser.parse_args().action certifi_path = where() if action == "add": print('Open Proxyman, go to "Certificate" -> "Export" -> "Root Certificate as PEM..." and save it somewhere.') proxyman_cert_path = input("Paste the path to the exported Certificate -> ") # Steps to verify if the cert is in great format and all to avoid # merging a shopping list or idk what to the certificates if len(proxyman_cert_path) < 4: exit("Invalid path.") if proxyman_cert_path.endswith((".pem'", '.pem"')): proxyman_cert_path = proxyman_cert_path[1:-1] if not proxyman_cert_path.endswith(".pem"): exit('The path must be pointing to a ".pem" certificate.') proxyman_cert_content = read_proxyman_cert(path=proxyman_cert_path) if not match(RE_CERT, proxyman_cert_content): exit(f'Invalid ".pem" file content (not matching re"{RE_CERT}").') # Checks if the certificate is already present in the certificate list if proxyman_cert_content in read_certifi(certifi_path=certifi_path): exit("This certificate is already present in certifi certificates.") # If it is all good, merge merge_cert(certifi_path=certifi_path, content=proxyman_cert_content) elif action == "remove": remove_cert(certifi_path=certifi_path) if __name__ == "__main__": main() ```
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 16, 2022):

Thanks for the script @novitae 🎉 . I will add it to the Python Document 🙌

<!-- gh-comment-id:1249942616 --> @NghiaTranUIT commented on GitHub (Sep 16, 2022): Thanks for the script @novitae 🎉 . I will add it to the Python Document 🙌
Author
Owner

@johnnyoshika commented on GitHub (Nov 14, 2023):

little update about this script, thanks to @azarouski

also added new path verification because the old one was trash

try:
    from certifi import where
except ModuleNotFoundError:
    exit('Please run "pip install certifi"')
from re import findall, match
from argparse import ArgumentParser

RE_CERT = r"-----BEGIN\ CERTIFICATE-----\n[A-Za-z0-9\/\+\n=]{1,}-----END\ CERTIFICATE-----\n"

def read_certifi(certifi_path:str) -> str:
    """Returns the content of cacert.pem of certifi"""
    with open(certifi_path, "r") as read:
        certifi_content = read.read()
    return certifi_content

def merge_cert(certifi_path:str, content:str) -> None:
    """Adds the content of Proxyman certificate to cacert.pem"""
    with open(certifi_path, "a") as append:
        # Appends the proxyman cert with "# Proxyman Root Certificate" written over
        # so we can find it back with regex
        append.write(f"\n# Proxyman Root Certificate\n{content}\n")
    print("Proxyman certificate succesfully added.")

def remove_cert(certifi_path:str) -> None:
    """Removes the Proxyman certificate of the cacert.pem"""
    certifi_content = read_certifi(certifi_path=certifi_path)
    proxyman_lines = findall(
        r"\n#\ Proxyman\ Root\ Certificate\n" + RE_CERT,
        certifi_content
    ) # Finds back the content of the previously added proxyman cert with regex
    
    if not proxyman_lines:
        exit("Proxyman certificate have not been added to your python certificates yet.")
    
    new_certifi_content = certifi_content.replace(proxyman_lines[0], "")
    
    # while there's two breakline at the end, we remove the last one
    while new_certifi_content[-2:] == "\n\n":
        new_certifi_content = new_certifi_content[:-1]

    with open(certifi_path, "w") as write:
        write.write(new_certifi_content)
    print("Proxyman certificate removed succesfully.")

def read_proxyman_cert(path: str) -> str:
    """Reads and return in str the content of the input certificate"""
    try:
        print(path)
        with open(path, "r") as read:
            content = read.read()
    except FileNotFoundError:
        exit("Please make sure the path to the exported Proxyman certificate is the right one.")
    return content

def main() -> None:
    parser = ArgumentParser()
    parser.add_argument("action", choices=["add", "remove"], help="choose to add or remove the proxyman certificate from your python certificates")
    action = parser.parse_args().action

    certifi_path = where()
    if action == "add":
        print('Open Proxyman, go to "Certificate" -> "Export" -> "Root Certificate as PEM..." and save it somewhere.')
        proxyman_cert_path = input("Paste the path to the exported Certificate -> ")

        # Steps to verify if the cert is in great format and all to avoid
        # merging a shopping list or idk what to the certificates
        if len(proxyman_cert_path) < 4:
            exit("Invalid path.")

        if proxyman_cert_path.endswith((".pem'", '.pem"')):
            proxyman_cert_path = proxyman_cert_path[1:-1]
        if not proxyman_cert_path.endswith(".pem"):
            exit('The path must be pointing to a ".pem" certificate.')
        proxyman_cert_content = read_proxyman_cert(path=proxyman_cert_path)
        if not match(RE_CERT, proxyman_cert_content):
            exit(f'Invalid ".pem" file content (not matching re"{RE_CERT}").')

        # Checks if the certificate is already present in the certificate list
        if proxyman_cert_content in read_certifi(certifi_path=certifi_path):
            exit("This certificate is already present in certifi certificates.")

        # If it is all good, merge
        merge_cert(certifi_path=certifi_path, content=proxyman_cert_content)

    elif action == "remove":
        remove_cert(certifi_path=certifi_path)

if __name__ == "__main__":
    main()

This is great! As the Windows version of Proxyman still doesn't offer the automatic setup option in Terminal, this script worked like a charm.

<!-- gh-comment-id:1810746025 --> @johnnyoshika commented on GitHub (Nov 14, 2023): > little update about this script, thanks to @azarouski > > also added new path verification because the old one was trash > > ```python > try: > from certifi import where > except ModuleNotFoundError: > exit('Please run "pip install certifi"') > from re import findall, match > from argparse import ArgumentParser > > RE_CERT = r"-----BEGIN\ CERTIFICATE-----\n[A-Za-z0-9\/\+\n=]{1,}-----END\ CERTIFICATE-----\n" > > def read_certifi(certifi_path:str) -> str: > """Returns the content of cacert.pem of certifi""" > with open(certifi_path, "r") as read: > certifi_content = read.read() > return certifi_content > > def merge_cert(certifi_path:str, content:str) -> None: > """Adds the content of Proxyman certificate to cacert.pem""" > with open(certifi_path, "a") as append: > # Appends the proxyman cert with "# Proxyman Root Certificate" written over > # so we can find it back with regex > append.write(f"\n# Proxyman Root Certificate\n{content}\n") > print("Proxyman certificate succesfully added.") > > def remove_cert(certifi_path:str) -> None: > """Removes the Proxyman certificate of the cacert.pem""" > certifi_content = read_certifi(certifi_path=certifi_path) > proxyman_lines = findall( > r"\n#\ Proxyman\ Root\ Certificate\n" + RE_CERT, > certifi_content > ) # Finds back the content of the previously added proxyman cert with regex > > if not proxyman_lines: > exit("Proxyman certificate have not been added to your python certificates yet.") > > new_certifi_content = certifi_content.replace(proxyman_lines[0], "") > > # while there's two breakline at the end, we remove the last one > while new_certifi_content[-2:] == "\n\n": > new_certifi_content = new_certifi_content[:-1] > > with open(certifi_path, "w") as write: > write.write(new_certifi_content) > print("Proxyman certificate removed succesfully.") > > def read_proxyman_cert(path: str) -> str: > """Reads and return in str the content of the input certificate""" > try: > print(path) > with open(path, "r") as read: > content = read.read() > except FileNotFoundError: > exit("Please make sure the path to the exported Proxyman certificate is the right one.") > return content > > def main() -> None: > parser = ArgumentParser() > parser.add_argument("action", choices=["add", "remove"], help="choose to add or remove the proxyman certificate from your python certificates") > action = parser.parse_args().action > > certifi_path = where() > if action == "add": > print('Open Proxyman, go to "Certificate" -> "Export" -> "Root Certificate as PEM..." and save it somewhere.') > proxyman_cert_path = input("Paste the path to the exported Certificate -> ") > > # Steps to verify if the cert is in great format and all to avoid > # merging a shopping list or idk what to the certificates > if len(proxyman_cert_path) < 4: > exit("Invalid path.") > > if proxyman_cert_path.endswith((".pem'", '.pem"')): > proxyman_cert_path = proxyman_cert_path[1:-1] > if not proxyman_cert_path.endswith(".pem"): > exit('The path must be pointing to a ".pem" certificate.') > proxyman_cert_content = read_proxyman_cert(path=proxyman_cert_path) > if not match(RE_CERT, proxyman_cert_content): > exit(f'Invalid ".pem" file content (not matching re"{RE_CERT}").') > > # Checks if the certificate is already present in the certificate list > if proxyman_cert_content in read_certifi(certifi_path=certifi_path): > exit("This certificate is already present in certifi certificates.") > > # If it is all good, merge > merge_cert(certifi_path=certifi_path, content=proxyman_cert_content) > > elif action == "remove": > remove_cert(certifi_path=certifi_path) > > if __name__ == "__main__": > main() > ``` This is great! As the Windows version of Proxyman still doesn't offer the automatic setup option in Terminal, this script worked like a charm.
Author
Owner

@NghiaTranUIT commented on GitHub (Nov 15, 2023):

Just a friendly reminder that this script can be automatically done with an Automatic Setup feature on the latest Proxyman macOS.

Just start the pre-configured Terminal -> Run your Python script here

Proxyman auto:

  • Override some ENV
  • Auto Install & Trust Proxyman Certificate into Python Store (No more custom scripts)

@johnnyoshika you're right, This feature is only available on the macOS. We soon support on Windows and Linux 👍

<!-- gh-comment-id:1811619710 --> @NghiaTranUIT commented on GitHub (Nov 15, 2023): Just a friendly reminder that this script can be automatically done with an [Automatic Setup](https://docs.proxyman.io/automatic-setup/automatic-setup) feature on the latest Proxyman macOS. Just start the pre-configured Terminal -> Run your Python script here Proxyman auto: - Override some ENV - Auto Install & Trust Proxyman Certificate into Python Store (No more custom scripts) ----------------- @johnnyoshika you're right, This feature is only available on the macOS. We soon support on Windows and Linux 👍
Author
Owner

@johnnyoshika commented on GitHub (Nov 15, 2023):

Just a friendly reminder that this script can be automatically done with an Automatic Setup feature on the latest Proxyman macOS.

Just start the pre-configured Terminal -> Run your Python script here

Proxyman auto:

  • Override some ENV
  • Auto Install & Trust Proxyman Certificate into Python Store (No more custom scripts)

@johnnyoshika you're right, This feature is only available on the macOS. We soon support on Windows and Linux 👍

Yes, on macOS it works great! You can even launch VSCode (code .) from a Proxyman launched terminal and VSCode's terminal will be configured to proxy through Proxyman as well. I tested this with Python and Node and they both worked well.

Windows on the other hand is much more difficult. I got python to work through the script provided above but I've been less successful with Node, despite following the Old Technique solutions here: https://docs.proxyman.io/debug-devices/nodejs

<!-- gh-comment-id:1811761088 --> @johnnyoshika commented on GitHub (Nov 15, 2023): > Just a friendly reminder that this script can be automatically done with an [Automatic Setup](https://docs.proxyman.io/automatic-setup/automatic-setup) feature on the latest Proxyman macOS. > > Just start the pre-configured Terminal -> Run your Python script here > > Proxyman auto: > > * Override some ENV > * Auto Install & Trust Proxyman Certificate into Python Store (No more custom scripts) > > @johnnyoshika you're right, This feature is only available on the macOS. We soon support on Windows and Linux 👍 Yes, on macOS it works great! You can even launch VSCode (`code .`) from a Proxyman launched terminal and VSCode's terminal will be configured to proxy through Proxyman as well. I tested this with Python and Node and they both worked well. Windows on the other hand is much more difficult. I got python to work through the script provided above but I've been less successful with Node, despite following the `Old Technique` solutions here: https://docs.proxyman.io/debug-devices/nodejs
Author
Owner

@NghiaTranUIT commented on GitHub (Nov 15, 2023):

May I ask @johnnyoshika

  • On your Windows machine, do you use Unix Terminal (WSL), Command Line or Powershell?
<!-- gh-comment-id:1811763494 --> @NghiaTranUIT commented on GitHub (Nov 15, 2023): May I ask @johnnyoshika - On your Windows machine, do you use Unix Terminal (WSL), Command Line or Powershell?
Author
Owner

@johnnyoshika commented on GitHub (Nov 15, 2023):

May I ask @johnnyoshika

  • On your Windows machine, do you use Unix Terminal (WSL), Command Line or Powershell?

I use both Powershell and WSL, but mostly Powershell

<!-- gh-comment-id:1811910555 --> @johnnyoshika commented on GitHub (Nov 15, 2023): > May I ask @johnnyoshika > > * On your Windows machine, do you use Unix Terminal (WSL), Command Line or Powershell? I use both Powershell and WSL, but mostly Powershell
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 26, 2024):

FYI: We can capture all HTTPS Traffic from Python with the Auto Setup (https://docs.proxyman.io/debug-devices/python)

No need to config the Proxy or manually trust the self-signed certificate on your Python code 👍

<!-- gh-comment-id:2376333289 --> @NghiaTranUIT commented on GitHub (Sep 26, 2024): FYI: We can capture all HTTPS Traffic from Python with the Auto Setup (https://docs.proxyman.io/debug-devices/python) No need to config the Proxy or manually trust the self-signed certificate on your Python code 👍
Author
Owner

@johnnyoshika commented on GitHub (Oct 5, 2024):

FYI: We can capture all HTTPS Traffic from Python with the Auto Setup (https://docs.proxyman.io/debug-devices/python)

No need to config the Proxy or manually trust the self-signed certificate on your Python code 👍

Even in Windows?

<!-- gh-comment-id:2395204501 --> @johnnyoshika commented on GitHub (Oct 5, 2024): > FYI: We can capture all HTTPS Traffic from Python with the Auto Setup (https://docs.proxyman.io/debug-devices/python) > > No need to config the Proxy or manually trust the self-signed certificate on your Python code 👍 Even in Windows?
Author
Owner

@NghiaTranUIT commented on GitHub (Oct 6, 2024):

@johnnyoshika Automatic Script is only available on Windows 👍

<!-- gh-comment-id:2395252022 --> @NghiaTranUIT commented on GitHub (Oct 6, 2024): @johnnyoshika Automatic Script is only available on Windows 👍
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#1214
No description provided.