大网数据广告活动
服务器运维问答

mTLS: restrict client cert to specific subdomain?

· 52CE 我爱测

tldr Via mTLS, I'm trying to find a way of issuing a client cert that only grants that client to access a specific subdomain. I have a suspicion that this isn't possible, but I'm not certain. What I'm trying to accomplish Let's s…

问题原文

原帖链接 · Joe · CC BY-SA 4.0

tldr

Via mTLS, I'm trying to find a way of issuing a client cert that only grants that client to access a specific subdomain. I have a suspicion that this isn't possible, but I'm not certain.

What I'm trying to accomplish

Let's say I have a server listening to anything routed to *.foo.flar.com

Each customer is assigned their own subdomain that satisfies the wildcard in the server's address.

For example, customer1 should access the server via customer1.foo.flar.com, and customer2 should access the server via customer2.foo.flar.com.

Further, one customer must be prevented from accessing the server using a different customer's subdomain. So, it is illegal for customer1 to request customer2.foo.flar.com, and such a request should be rejected.

I was hoping that I could accomplish this at the session layer via mTLS and some clever SAN cert usage, but I'm having trouble getting it to work properly.

How I have things setup

I'm pretty new to playing around with TLS, so a lot of this came from this SO answer about SAN configuration and this article about basic mTLS configuration.

I've omitted some things here like CA cert generation and client and server CSR generation to try and keep things focused, but can add it if you'd like.

I created a server cert using something like:

openssl x509 \
  -req \
  -extfile <(printf "subjectAltName=DNS:*.foo.flar.com") \
  -days 365 \
  -in server.csr \ 
  -CA ca.crt \
  -CAkey ca.key \
  -CAcreateserial \
  -out server.crt

Then I created a client cert using something like:

openssl x509 \
  -req \
  -extfile <(printf "subjectAltName=DNS:customer1.foo.flar.com") \
  -days 365 \
  -in client.csr \ 
  -CA ca.crt \
  -CAkey ca.key \
  -CAcreateserial \
  -out client.crt

The server (written in Go) is configured to require and verify client certs.

The problem

The problem is that when I test this setup, the connection succeeds when I would expect it to fail.

If I have a client issued the customer1 cert call the server at customer1.foo.flar.com, the connection succeeds.

However, if I have a client issued the customer1 cert call the server at customer2.foo.flar.com, that connection also succeeds when I would expect it to fail.

I was hoping that, upon inspection of the client's cert, the server would see that customer1 does not have access to customer2..., and would reject the request. But this does not seem to be happening.

Ideas?

已采纳解答

原帖链接 · Steffen Ullrich · CC BY-SA 4.0

Client certificates contain only the information to authenticate the user. Any restrictions on what the authenticated user can do (authorization) including on which site the certificate will be accepted are up to the server who checks the certificate.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-12-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。