tailscale/feature/tpm/tpm_linux.go
Andrew Lytvynov 6c206fab58
feature/tpm: try opening /dev/tpmrm0 before /tmp/tpm0 on Linux (#16600)
The tpmrm0 is a kernel-managed version of tpm0 that multiplexes multiple
concurrent connections. The basic tpm0 can only be accessed by one
application at a time, which can be pretty unreliable.

Updates #15830

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2025-07-18 10:17:40 -07:00

18 lines
363 B
Go

// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
package tpm
import (
"github.com/google/go-tpm/tpm2/transport"
"github.com/google/go-tpm/tpm2/transport/linuxtpm"
)
func open() (transport.TPMCloser, error) {
tpm, err := linuxtpm.Open("/dev/tpmrm0")
if err == nil {
return tpm, nil
}
return linuxtpm.Open("/dev/tpm0")
}