Skip to content

Commit

Permalink
chore: update example code to use HTTPS
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Fossati <[email protected]>
  • Loading branch information
thomas-fossati committed Dec 11, 2024
1 parent b8b092b commit 7db3def
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
16 changes: 11 additions & 5 deletions examples/challenge_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,30 @@ fn my_evidence_builder(nonce: &[u8], accept: &[String]) -> Result<(Vec<u8>, Stri
}

fn main() {
let base_url = "http://127.0.0.1:8080";
let base_url = "https://localhost:8080";

let discovery = Discovery::from_base_url(String::from(base_url))
.expect("Failed to start API discovery with the service.");
let discovery_api_endpoint = format!("{}{}", base_url, "/.well-known/veraison/verification");

let discovery = DiscoveryBuilder::new()
.with_url(discovery_api_endpoint)
.with_root_certificate("veraison-root.crt".into())
.build()
.expect("Failed to start API discovery with the service");

let verification_api = discovery
.get_verification_api()
.expect("Failed to discover the verification endpoint details.");
.expect("Failed to discover the verification endpoint details");

let relative_endpoint = verification_api
.get_api_endpoint("newChallengeResponseSession")
.expect("Could not locate a newChallengeResponseSession endpoint.");
.expect("Could not locate a newChallengeResponseSession endpoint");

let api_endpoint = format!("{}{}", base_url, relative_endpoint);

// create a ChallengeResponse object
let cr = ChallengeResponseBuilder::new()
.with_new_session_url(api_endpoint)
.with_root_certificate("veraison-root.crt".into())
.build()
.unwrap();

Expand Down
10 changes: 10 additions & 0 deletions examples/veraison-root.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----BEGIN CERTIFICATE-----
MIIBfDCCASGgAwIBAgIUGFllXaV04uJz42tPnHXwOkaux50wCgYIKoZIzj0EAwIw
EzERMA8GA1UECgwIVmVyYWlzb24wHhcNMjQwNTIxMTAxNzA1WhcNMzQwNTE5MTAx
NzA1WjATMREwDwYDVQQKDAhWZXJhaXNvbjBZMBMGByqGSM49AgEGCCqGSM49AwEH
A0IABCYxQeR0gnM4/4CvQBmIgNSm6SAal29OYm7GBpq/y0rZWolA3FlHChm3nIZe
qXAtKvK4rkolWSLiaRNN1mEWYG6jUzBRMB0GA1UdDgQWBBTq/aQhL7+hx9EOG+X0
Q/YbAWuGDjAfBgNVHSMEGDAWgBTq/aQhL7+hx9EOG+X0Q/YbAWuGDjAPBgNVHRMB
Af8EBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQCAqRST0CFtgWVXpBtYoTldREXb
hGryGCivO3Jkv6LZ5wIhAMqlRBGBPbz8sgS+QQCA0pbhXFt7kMQpH3hrR/tEIeW2
-----END CERTIFICATE-----

0 comments on commit 7db3def

Please sign in to comment.