Skip to content

tls: failed to verify certificate: x509: certificate is valid for xx, not xxx #12470

Open
@richardwu0313

Description

Before you start please confirm the following.

Problem Description

failed to create portainer endpoint by api, while creating endpint in GUI is succeed.

Expected Behavior

create endpint succeed

Actual Behavior

Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/apple/Desktop/flexiv_gitlab/study/portainer_ce_study/test_portainer.py", line 14, in
endpoint_objs = FvrPortainerUtil.create_endpoints()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/apple/Desktop/flexiv_gitlab/study/portainer_ce_study/fvr_portainer_util.py", line 98, in create_endpoints
obj = api.endpoint_create(
^^^^^^^^^^^^^^^^^^^^
File "/Users/apple/Desktop/flexiv_gitlab/study/portainer_ce_study/swagger_client/api/endpoints_api.py", line 166, in endpoint_create
(data) = self.endpoint_create_with_http_info(name, endpoint_creation_type, edge_tunnel_server_address, **kwargs) # noqa: E501
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/apple/Desktop/flexiv_gitlab/study/portainer_ce_study/swagger_client/api/endpoints_api.py", line 290, in endpoint_create_with_http_info
return self.api_client.call_api(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/apple/Desktop/flexiv_gitlab/study/portainer_ce_study/swagger_client/api_client.py", line 325, in call_api
return self.__call_api(resource_path, method,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/apple/Desktop/flexiv_gitlab/study/portainer_ce_study/swagger_client/api_client.py", line 157, in __call_api
response_data = self.request(
^^^^^^^^^^^^^
File "/Users/apple/Desktop/flexiv_gitlab/study/portainer_ce_study/swagger_client/api_client.py", line 367, in request
return self.rest_client.POST(url,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/apple/Desktop/flexiv_gitlab/study/portainer_ce_study/swagger_client/rest.py", line 269, in POST
return self.request("POST", url,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/apple/Desktop/flexiv_gitlab/study/portainer_ce_study/swagger_client/rest.py", line 228, in request
raise ApiException(http_resp=r)
swagger_client.rest.ApiException: (500)
Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'X-Content-Type-Options': 'nosniff', 'Date': 'Mon, 06 Jan 2025 07:57:34 GMT', 'Content-Length': '188'})
HTTP response body: {"message":"Unable to get environment type","details":"Get "https://xxxx:29001/ping\": tls: failed to verify certificate: x509: certificate is valid for xx, not xxxx"}

Steps to Reproduce

        obj =  api.endpoint_create(
            name="ep1",
            endpoint_creation_type=2,
            group_id=1,
            url="tcp://xxxx:9001",
            tls=True,
            tls_skip_verify=True,
            tls_skip_client_verify=True,
            edge_tunnel_server_address="",)

Portainer logs or screenshots

No response

Portainer version

2.21.5

Portainer Edition

Community Edition (CE)

Platform and Version

Docker version 27.3.1

OS and Architecture

ubuntu 22.04

Browser

No response

What command did you use to deploy Portainer?

No response

Additional Information

No response

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions