diff --git a/examples/challenge_response.rs b/examples/challenge_response.rs index e5e089e..c893a2f 100644 --- a/examples/challenge_response.rs +++ b/examples/challenge_response.rs @@ -18,24 +18,30 @@ fn my_evidence_builder(nonce: &[u8], accept: &[String]) -> Result<(Vec, 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(); diff --git a/examples/veraison-root.crt b/examples/veraison-root.crt new file mode 100644 index 0000000..e894c3d --- /dev/null +++ b/examples/veraison-root.crt @@ -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-----