Updated the code to print out the available Restful URIs. Added some

modifications to the provisioner code for testing and updated the
Restful base mapping
This commit is contained in:
Cyrus 2023-09-14 09:14:11 -04:00
parent 6b063d44e0
commit 771d5588d5
5 changed files with 36 additions and 10 deletions

View File

@ -8,9 +8,9 @@ import hirs.attestationca.persist.entity.manager.PolicyRepository;
import hirs.attestationca.persist.entity.manager.ReferenceDigestValueRepository; import hirs.attestationca.persist.entity.manager.ReferenceDigestValueRepository;
import hirs.attestationca.persist.entity.manager.ReferenceManifestRepository; import hirs.attestationca.persist.entity.manager.ReferenceManifestRepository;
import hirs.attestationca.persist.entity.manager.TPM2ProvisionerStateRepository; import hirs.attestationca.persist.entity.manager.TPM2ProvisionerStateRepository;
import hirs.attestationca.persist.entity.userdefined.certificate.IssuedAttestationCertificate;
import hirs.attestationca.persist.service.SupplyChainValidationService; import hirs.attestationca.persist.service.SupplyChainValidationService;
import hirs.structs.converters.StructConverter; import hirs.structs.converters.StructConverter;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
@ -31,7 +31,7 @@ import java.security.cert.X509Certificate;
@PropertySource(value = "file:/etc/hirs/aca/application.properties", @PropertySource(value = "file:/etc/hirs/aca/application.properties",
ignoreResourceNotFound = true) ignoreResourceNotFound = true)
@RestController @RestController
@RequestMapping("/") @RequestMapping("/client")
public class RestfulAttestationCertificateAuthority extends AttestationCertificateAuthority implements RestfulInterface { public class RestfulAttestationCertificateAuthority extends AttestationCertificateAuthority implements RestfulInterface {
/** /**

View File

@ -0,0 +1,26 @@
package hirs.attestationca.portal.listener;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import java.util.Map;
@Log4j2
@Configuration
public class AnnotationDrivenEndpointsListener {
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
ApplicationContext applicationContext = event.getApplicationContext();
RequestMappingHandlerMapping requestMappingHandlerMapping = applicationContext
.getBean("requestMappingHandlerMapping", RequestMappingHandlerMapping.class);
Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods();
map.forEach((key, value) -> log.debug("{} {}", key, value));
}
}

View File

@ -66,7 +66,6 @@ echo "----> Downloading truststore" | tee -a $PROVISIONER_LOG_FILE
wget https://"$ATTESTATION_CA_FQDN":"$ATTESTATION_CA_PORT"/HIRS_AttestationCA/client-files/TrustStore.jks --no-check-certificate -P ${CERTIFICATES} >/dev/null 2>/dev/null wget https://"$ATTESTATION_CA_FQDN":"$ATTESTATION_CA_PORT"/HIRS_AttestationCA/client-files/TrustStore.jks --no-check-certificate -P ${CERTIFICATES} >/dev/null 2>/dev/null
if [ ! -f "${CERTIFICATES}/TrustStore.jks" ]; then if [ ! -f "${CERTIFICATES}/TrustStore.jks" ]; then
echo "----> ERROR: Truststore could not be downloaded from $ATTESTATION_CA_FQDN" | tee -a $PROVISIONER_LOG_FILE echo "----> ERROR: Truststore could not be downloaded from $ATTESTATION_CA_FQDN" | tee -a $PROVISIONER_LOG_FILE
exit 1
fi fi
sed -i "s/provisioner\.aca\.host\s*=\s*.*/provisioner.aca.host = $ATTESTATION_CA_FQDN/" $PROVISIONER_PROPERTIES sed -i "s/provisioner\.aca\.host\s*=\s*.*/provisioner.aca.host = $ATTESTATION_CA_FQDN/" $PROVISIONER_PROPERTIES

View File

@ -65,7 +65,8 @@ string RestfulClientProvisioner::sendIdentityClaim(
// Send serialized Identity Claim to ACA // Send serialized Identity Claim to ACA
LOGGER.info("Sending Serialized Identity Claim Binary"); LOGGER.info("Sending Serialized Identity Claim Binary");
auto r = cpr::Post(cpr::Url{"https://" + acaAddress + ":" + to_string(port) auto r = cpr::Post(cpr::Url{"https://" + acaAddress + ":" + to_string(port)
+ "/HIRS_AttestationCA/identity-claim-tpm2/" + "/HIRS_AttestationCA/portal/"
+ "client/identity-claim-tpm2/"
+ "process"}, + "process"},
cpr::Body{identityClaimByteString}, cpr::Body{identityClaimByteString},
cpr::Header{{"Content-Type", cpr::Header{{"Content-Type",
@ -121,7 +122,7 @@ string RestfulClientProvisioner::sendAttestationCertificateRequest(
// Send serialized certificate request to ACA // Send serialized certificate request to ACA
LOGGER.info("Sending Serialized DeviceInfo Binary"); LOGGER.info("Sending Serialized DeviceInfo Binary");
auto r = cpr::Post(cpr::Url{"https://" + acaAddress + ":" + to_string(port) auto r = cpr::Post(cpr::Url{"https://" + acaAddress + ":" + to_string(port)
+ "/HIRS_AttestationCA" + "/HIRS_AttestationCA/portal/client"
+ "/request-certificate-tpm2"}, + "/request-certificate-tpm2"},
cpr::Body{certificateRequestByteString}, cpr::Body{certificateRequestByteString},
cpr::Header{{"Content-Type", cpr::Header{{"Content-Type",

View File

@ -62,12 +62,12 @@ int provision() {
// get platform credential // get platform credential
cout << "----> Collecting platform credential from TPM" << endl; cout << "----> Collecting platform credential from TPM" << endl;
string platformCredential = tpm2.getPlatformCredentialDefault(); // string platformCredential = tpm2.getPlatformCredentialDefault();
std::vector<string> platformCredentials; std::vector<string> platformCredentials;
// if platformCredential is empty, not in TPM // if platformCredential is empty, not in TPM
// pull from properties file // pull from properties file
if (platformCredential.empty()) { // if (platformCredential.empty()) {
const std::string& cert_dir = const std::string& cert_dir =
props.get( props.get(
"tcg.cert.dir", "tcg.cert.dir",
@ -78,9 +78,9 @@ int provision() {
} catch (HirsRuntimeException& hirsRuntimeException) { } catch (HirsRuntimeException& hirsRuntimeException) {
logger.error(hirsRuntimeException.what()); logger.error(hirsRuntimeException.what());
} }
} else { // } else {
platformCredentials.push_back(platformCredential); // platformCredentials.push_back(platformCredential);
} // }
// collect device info // collect device info
cout << "----> Collecting device information" << endl; cout << "----> Collecting device information" << endl;