-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
278 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
load("//tools/lint:go.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["fetcher.go"], | ||
importpath = "github.com/scionproto/scion/private/trust/connect", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//bufgen/proto/control_plane/v1/control_planeconnect:go_default_library", | ||
"//pkg/addr:go_default_library", | ||
"//pkg/connect:go_default_library", | ||
"//pkg/private/serrors:go_default_library", | ||
"//pkg/scrypto/cppki:go_default_library", | ||
"//pkg/snet/squic:go_default_library", | ||
"//private/trust:go_default_library", | ||
"//private/trust/grpc:go_default_library", | ||
"@com_connectrpc_connect//:go_default_library", | ||
"@com_github_quic_go_quic_go//http3:go_default_library", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package connect | ||
|
||
import ( | ||
"context" | ||
"crypto/x509" | ||
"net" | ||
|
||
"connectrpc.com/connect" | ||
"github.com/quic-go/quic-go/http3" | ||
"github.com/scionproto/scion/bufgen/proto/control_plane/v1/control_planeconnect" | ||
"github.com/scionproto/scion/pkg/addr" | ||
libconnect "github.com/scionproto/scion/pkg/connect" | ||
"github.com/scionproto/scion/pkg/private/serrors" | ||
"github.com/scionproto/scion/pkg/scrypto/cppki" | ||
"github.com/scionproto/scion/pkg/snet/squic" | ||
"github.com/scionproto/scion/private/trust" | ||
"github.com/scionproto/scion/private/trust/grpc" | ||
) | ||
|
||
type Fetcher struct { | ||
// IA is the local ISD-AS. | ||
IA addr.IA | ||
// Dialer dials a new gRPC connection. | ||
Dialer func(net.Addr, ...squic.EarlyDialerOption) squic.EarlyDialer | ||
} | ||
|
||
// Chains fetches certificate chains over the network | ||
func (f Fetcher) Chains(ctx context.Context, query trust.ChainQuery, | ||
server net.Addr) ([][]*x509.Certificate, error) { | ||
|
||
dialer := f.Dialer(server) | ||
client := control_planeconnect.NewTrustMaterialServiceClient( | ||
libconnect.HTTPClient{ | ||
RoundTripper: &http3.RoundTripper{ | ||
Dial: dialer.DialEarly, | ||
}, | ||
}, | ||
libconnect.BaseUrl(server), | ||
) | ||
rep, err := client.Chains(ctx, connect.NewRequest(grpc.ChainQueryToReq(query))) | ||
if err != nil { | ||
return nil, serrors.WrapStr("fetching chains over connect", err) | ||
} | ||
chains, _, err := grpc.RepToChains(rep.Msg.Chains) | ||
if err != nil { | ||
return nil, serrors.WrapStr("parsing chains", err) | ||
} | ||
if err := grpc.CheckChainsMatchQuery(query, chains); err != nil { | ||
return nil, serrors.WrapStr("chains do not match query", err) | ||
} | ||
return chains, nil | ||
} | ||
|
||
func (f Fetcher) TRC(ctx context.Context, id cppki.TRCID, | ||
server net.Addr) (cppki.SignedTRC, error) { | ||
|
||
dialer := f.Dialer(server) | ||
client := control_planeconnect.NewTrustMaterialServiceClient( | ||
libconnect.HTTPClient{ | ||
RoundTripper: &http3.RoundTripper{ | ||
Dial: dialer.DialEarly, | ||
}, | ||
}, | ||
libconnect.BaseUrl(server), | ||
) | ||
rep, err := client.TRC(ctx, connect.NewRequest(grpc.IDToReq(id))) | ||
if err != nil { | ||
return cppki.SignedTRC{}, serrors.WrapStr("fetching chains over connect", err) | ||
} | ||
trc, err := cppki.DecodeSignedTRC(rep.Msg.Trc) | ||
if err != nil { | ||
return cppki.SignedTRC{}, serrors.WrapStr("parse TRC reply", err) | ||
} | ||
if trc.TRC.ID != id { | ||
return cppki.SignedTRC{}, serrors.New("received wrong TRC", "expected", id, | ||
"actual", trc.TRC.ID) | ||
} | ||
return trc, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
load("//tools/lint:go.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["fetcher.go"], | ||
importpath = "github.com/scionproto/scion/private/trust/happy", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/log:go_default_library", | ||
"//pkg/private/serrors:go_default_library", | ||
"//pkg/scrypto/cppki:go_default_library", | ||
"//private/trust:go_default_library", | ||
], | ||
) |
Oops, something went wrong.