Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
343 views
in Technique[技术] by (71.8m points)

ssl - How to have asp.net core running locally with HTTPS in Kubernetes

I Currently have a docker-compose setup for Asp.Net Core. However when moving to test the cluster in Kubernetes I ran into SSL issues with Kestral. Originally with Docker/Docker-compose you can set up local SSL with

dotnet dev-certs https -ep %USERPROFILE%.aspnethttps<app_name>.pfx -p <password>

Then

dotnet dev-certs https --trust

Finally

dotnet user-secrets set "Kestrel:Certificates:Development:Password" "<password>"

And in Docker-compose I setup the volumes to point to this cert

volumes:
      - ${APPDATA}microsoftUserSecrets:/root/.microsoft/usersecrets
      - ${USERPROFILE}.aspnethttps:/root/.aspnet/https/

I am curious how I can test locally https with kubernetes. I saw a git repo https://github.com/Lybecker/k8s-friendly-aspnetcore, however I did not figure out how to get the .pfx file from my local computer into the secret, I would think copy and paste is not the way to go.

I looked at this SO post Access .NET Core app on Kubernetes on both http and https

However it looks like they are using .Net 5 which uses .key and .crt. I am on .Net 3.1 which uses a .pfx file.

question from:https://stackoverflow.com/questions/65943983/how-to-have-asp-net-core-running-locally-with-https-in-kubernetes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Rather than deploying your .NET core container with https, you should deploy it with http and use nginx-ingress to provide https as described here https://cert-manager.io/docs/tutorials/acme/ingress/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...