ratls

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const DefaultPCCSURL = "https://pccs.phala.network"

DefaultPCCSURL is the default PCCS server for collateral fetching.

Variables

This section is empty.

Functions

func TLSConfig

func TLSConfig(opts ...Option) *tls.Config

TLSConfig returns a *tls.Config that verifies the server's RA-TLS certificate during the TLS handshake.

Standard CA chain verification is skipped because RA-TLS certificates are self-signed; trust is established through hardware attestation instead.

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

func WithPCCSURL(url string) Option

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)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL