Documentation
¶
Overview ¶
Package ratls provides RA-TLS certificate verification for dstack TEE applications.
RA-TLS embeds TDX attestation quotes into X.509 certificate extensions. This package extracts and verifies those quotes, proving the certificate holder is running inside a genuine TEE.
Index ¶
Examples ¶
Constants ¶
const DefaultPCCSURL = "https://pccs.phala.network"
DefaultPCCSURL is the default PCCS server for collateral fetching.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*config)
Option configures RA-TLS verification.
func WithOnVerified ¶
func WithOnVerified(fn func(*VerifyResult)) Option
WithOnVerified sets a callback invoked after successful verification. Use this with TLSConfig to inspect the VerifyResult.
func WithPCCSURL ¶
WithPCCSURL sets the PCCS server URL for collateral fetching.
type VerifyResult ¶
type VerifyResult struct {
// Report is the dcap-qvl verification report including TCB status and advisory IDs.
Report *dcap.VerifiedReport
// Quote is the parsed TDX quote structure with measurements and report data.
Quote *dcap.Quote
}
VerifyResult contains the result of a successful RA-TLS verification.
func VerifyCert ¶
func VerifyCert(cert *x509.Certificate, opts ...Option) (*VerifyResult, error)
VerifyCert verifies that an X.509 certificate is a valid RA-TLS certificate.
It extracts the embedded TDX quote, verifies it via dcap-qvl, checks that the quote's report_data binds to the certificate's public key, validates TCB attributes (debug mode, signer), and replays RTMR3 from the event log.
Example ¶
ExampleVerifyCert demonstrates verifying an RA-TLS certificate from a TLS connection.
package main
import (
"crypto/tls"
"fmt"
"github.com/Dstack-TEE/dstack/sdk/go/ratls"
)
func main() {
conn, err := tls.Dial("tcp", "myapp-8443s.phala.network:443", &tls.Config{
InsecureSkipVerify: true,
})
if err != nil {
panic(err)
}
defer conn.Close()
cert := conn.ConnectionState().PeerCertificates[0]
result, err := ratls.VerifyCert(cert)
if err != nil {
fmt.Printf("verification failed: %v\n", err)
return
}
fmt.Printf("verified: status=%s\n", result.Report.Status)
}
Output: