mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-20 21:43:18 +00:00
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:
parent
6b063d44e0
commit
771d5588d5
@ -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 {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
||||||
|
@ -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",
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user