Skip to content

TLS Enabled on ECS Service Connect not working, Certificate verification unsuccessful

0

Hi, I was trying to enable TLS on my service for encrypted service-to-service communication. I followed this guide. But when I tried to verify if the TLS was enabled successfully (I followed this guide - I got this error:

Command: openssl s_client -connect 192.168.92.125:80 < /dev/null 2> /dev/null | openssl x509 -noout -text Output:

Could not read certificate from <stdin>
48EB9A21CB7F0000:error:1608010C:STORE routines:ossl_store_handle_load_result:unsupported:crypto/store/store_result.c:151:

I ran the command inside my task container where the TLS was enabled. I am just a newbie in tech and am not familiar with how these things work. I hope someone can help me troubleshoot further.

So these were my configurations:

  • AWS Private CA

    • Mode Options: Short-lived certificates
    • CA Type: Root
    • Key Algo: RSA 2048
    • Added a tag: AmazonECSManaged: true
  • Attach this policy to the role I used -AmazonECSInfrastructureRolePolicyForServiceConnectTransportLayerSecurity

  • KMSKey - I selected AWS Managed

  • Task Definition

{
    "family": "svc-3",
    "containerDefinitions": [
        {
            "name": "backend-copy",
            "image": "252711609309.dkr.ecr.ap-southeast-2.amazonaws.com/hello-world/api:59800f63",
            "cpu": 0,
            "portMappings": [
                {
                    "name": "backend-copy",
                    "containerPort": 80,
                    "hostPort": 80,
                    "protocol": "tcp",
                    "appProtocol": "http"
                }
            ],
            "essential": true,
            "environment": [],
            "mountPoints": [],
            "volumesFrom": [],
            "logConfiguration": {
                "logDriver": "awslogs",
                "options": {
                    "awslogs-group": "/ecs/svc-3",
                    "mode": "non-blocking",
                    "awslogs-create-group": "true",
                    "max-buffer-size": "25m",
                    "awslogs-region": "ap-southeast-2",
                    "awslogs-stream-prefix": "ecs"
                }
            },
            "systemControls": []
        }
    ],
    "taskRoleArn": "arn:aws:iam::<AWS-ID>:role/fargate-test-task-role",
    "executionRoleArn": "arn:aws:I am::<AWS-ID>:role/fargate-test-task-exec-role",
    "networkMode": "awsvpc",
    "volumes": [],
    "placementConstraints": [],
    "requiresCompatibilities": [
        "FARGATE"
    ],
    "cpu": "256",
    "memory": "512",
    "runtimePlatform": {
        "cpuArchitecture": "X86_64",
        "operatingSystemFamily": "LINUX"
    },
    "enableFaultInjection": false
}

I can curl my API endpoint from my other service, but TLS was not just working.

1 Answer
1
Accepted Answer

I believe there may be a little confusion here. The TLS Service connect feature doesnt encrypt traffic to your web service (hello-world container) Service that is running on ECS.

You still need to have your own TLS Setup either natively or via an ALB with a TLS Listener if you want to encrypt traffic to your hello-world app.

The TLS for Service connect is to encrypt traffic between the Service Connect Proxies within ECS

Enter image description here

Service Connect initiates TLS at the Service Connect agent and terminates it at the destination agent. As a result, the application code never sees TLS interactions. Use the following steps to verify that TLS is enabled. https://docs.aws.amazon.com/AmazonECS/latest/developerguide/verify-tls-enabled.html

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

  • Hi Gary, thank you for answering. I see, my assumption was wrong, I thought that enabling the TLS in service connect would encrypt the communication between services. So the encryption is between the Service Connect proxies, not the direct communication with your application services? Did I understand it correctly? I am still new to this, I am sorry for the dumb questions. What I want to do is encrypt the communication between my two app services and I have been looking for some tutorials/ articles, but I haven't found some or probably I don't know what to look for.

  • It encyrpts communication where services route via the Proxy sidecarts. As per diagram, if you have a wordpress service and a mysql service which communication to each other via Service connect, the data is tunneled via the proxy and the proxy to proxy communication is encyrpted. You do not see this as per documentation as far as your app is concerned, its talking natively. Communication direct to you hello-world app from out side of ECS is not encrypted with Service Connect Encryption.. You can test TLS is enabled by connecting to the PROXY IP as per your openssl test, however you were testing access to PORT 80 on your container.

    Do you have more information on your 2 app services?

    No question is dumb.. We are all here to learn from each other.. Im learning all the time :-)

  • Please remember to accept the question if the answer was to your satification.. Cheers Gary

  • Hi Gary. I see, so I was verifying in the wrong place. I assumed that I would test it inside the container itself. Where can I find the proxy's IP? I just really followed the guide straightforwardly.

    My current setup is like this:

    The frontend has service connect enabled, but only set as the client. I attached an ALB with listener port 443. The API service has service connect enabled as well (client-server), no ALB attached, and has TLS enabled and that's it.

  • My goal is to make the endpoint of API to use https protocol coz if using the service connect name as is http://<service-connect-name>:80, it causes mismatch issue when my frontend tries to connect. And I'm still figuring out how to resolve this. I wanna use the native tools AWS have as per docu, use the AWS Private CA, but I am not sure how to configure it.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.