Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
c3bbc1ca
Commit
c3bbc1ca
authored
Nov 23, 2021
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Improve documentation
parent
3a0bb1fd
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!117
Release
,
!74
Implement bindings for downloading and verifying signed partial NDF
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/ndf.go
+13
-16
13 additions, 16 deletions
bindings/ndf.go
with
13 additions
and
16 deletions
bindings/ndf.go
+
13
−
16
View file @
c3bbc1ca
...
@@ -22,10 +22,9 @@ import (
...
@@ -22,10 +22,9 @@ import (
// ndfUrl is a hardcoded url to a bucket containing the signed NDF message.
// ndfUrl is a hardcoded url to a bucket containing the signed NDF message.
const
ndfUrl
=
`elixxir.io`
const
ndfUrl
=
`elixxir.io`
// DownloadSignedNdf retrieves the NDF from a hardcoded bucket URL.
// DownloadSignedNdf retrieves the NDF from a hardcoded bucket URL.
// The NDF returned requires further processing and verification
// The NDF returned requires further processing and verification
// before being used. Use
Verify
SignedNdf to properly process
// before being used. Use
Process
SignedNdf to properly process
// the downloaded data returned.
// the downloaded data returned.
// DO NOT USE THE RETURNED DATA TO START A CLIENT.
// DO NOT USE THE RETURNED DATA TO START A CLIENT.
func
DownloadSignedNdf
()
([]
byte
,
error
)
{
func
DownloadSignedNdf
()
([]
byte
,
error
)
{
...
@@ -49,10 +48,10 @@ func DownloadSignedNdf() ([]byte, error) {
...
@@ -49,10 +48,10 @@ func DownloadSignedNdf() ([]byte, error) {
// DownloadSignedNdfWithUrl retrieves the NDF from a specified URL.
// DownloadSignedNdfWithUrl retrieves the NDF from a specified URL.
// The NDF returned requires further processing and verification
// The NDF returned requires further processing and verification
// before being used. Use
Verify
SignedNdf to properly process
// before being used. Use
Process
SignedNdf to properly process
// the downloaded data returned.
// the downloaded data returned.
// DO NOT USE THE RETURNED DATA TO START A CLIENT.
// DO NOT USE THE RETURNED DATA TO START A CLIENT.
func
DownloadSignedNdfWithUrl
(
url
,
cert
string
)
([]
byte
,
error
)
{
func
DownloadSignedNdfWithUrl
(
url
string
)
([]
byte
,
error
)
{
// Build a reqeust for the file
// Build a reqeust for the file
resp
,
err
:=
http
.
Get
(
url
)
resp
,
err
:=
http
.
Get
(
url
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -71,13 +70,13 @@ func DownloadSignedNdfWithUrl(url, cert string) ([]byte, error) {
...
@@ -71,13 +70,13 @@ func DownloadSignedNdfWithUrl(url, cert string) ([]byte, error) {
return
signedNdfEncoded
,
nil
return
signedNdfEncoded
,
nil
}
}
//
Verify
SignedNdf takes the downloaded NDF from either
//
Process
SignedNdf takes the downloaded NDF from either
// DownloadSignedNdf or DownloadSignedNdfWithUrl (signedNdfEncoded)
// DownloadSignedNdf or DownloadSignedNdfWithUrl (signedNdfEncoded)
// an the scheduling certificate (cert). The downloaded NDF is parsed
// an
d
the scheduling certificate (cert). The downloaded NDF is parsed
// into a protobuf containing a signature. The signature is verified using the
// into a protobuf containing a signature. The signature is verified using the
// passed in cert. Upon successful parsing and verification, the NDF is
// passed in cert. Upon successful parsing and verification, the NDF is
// returned
. This
may be used to start a client.
// returned
as byte data, which
may be used to start a client.
func
Verify
SignedNdf
(
signedNdfEncoded
[]
byte
,
cert
string
)
([]
byte
,
error
)
{
func
Process
SignedNdf
(
signedNdfEncoded
[]
byte
,
cert
string
)
([]
byte
,
error
)
{
// Base64 decode the signed NDF
// Base64 decode the signed NDF
signedNdfMarshaled
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
signedNdfMarshaled
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
string
(
signedNdfEncoded
))
string
(
signedNdfEncoded
))
...
@@ -93,7 +92,6 @@ func VerifySignedNdf(signedNdfEncoded []byte, cert string) ([]byte, error) {
...
@@ -93,7 +92,6 @@ func VerifySignedNdf(signedNdfEncoded []byte, cert string) ([]byte, error) {
"signed NDF into protobuf"
)
"signed NDF into protobuf"
)
}
}
// Load the certificate from it's PEM contents
// Load the certificate from it's PEM contents
schedulingCert
,
err
:=
tls
.
LoadCertificate
(
cert
)
schedulingCert
,
err
:=
tls
.
LoadCertificate
(
cert
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -114,4 +112,3 @@ func VerifySignedNdf(signedNdfEncoded []byte, cert string) ([]byte, error) {
...
@@ -114,4 +112,3 @@ func VerifySignedNdf(signedNdfEncoded []byte, cert string) ([]byte, error) {
return
signedNdfMsg
.
Ndf
,
nil
return
signedNdfMsg
.
Ndf
,
nil
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment