Compare commits
	
		
			1 Commits
		
	
	
		
			8af3018b34
			...
			eb42cd629e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| eb42cd629e | 
@@ -16,13 +16,11 @@ impl CRLDistributionPointExt {
 | 
			
		||||
        let crl_bytes = asn1::write(|w| {
 | 
			
		||||
            w.write_element(&asn1::SequenceWriter::new(&|w| {
 | 
			
		||||
                w.write_element(&asn1::SequenceWriter::new(&|w| {
 | 
			
		||||
                    w.write_tlv(tag_a0, None, |w: &mut asn1::WriteBuf| {
 | 
			
		||||
                    w.write_tlv(tag_a0, |w| {
 | 
			
		||||
                        w.push_slice(&asn1::write(|w| {
 | 
			
		||||
                            w.write_tlv(tag_a0, None, |w: &mut asn1::WriteBuf| {
 | 
			
		||||
                            w.write_tlv(tag_a0, |w| {
 | 
			
		||||
                                w.push_slice(&asn1::write(|w| {
 | 
			
		||||
                                    w.write_tlv(tag_86, None, |b| {
 | 
			
		||||
                                        b.push_slice(self.url.as_bytes())
 | 
			
		||||
                                    })?;
 | 
			
		||||
                                    w.write_tlv(tag_86, |b| b.push_slice(self.url.as_bytes()))?;
 | 
			
		||||
                                    Ok(())
 | 
			
		||||
                                })?)
 | 
			
		||||
                            })?;
 | 
			
		||||
 
 | 
			
		||||
@@ -174,16 +174,17 @@ fn gen_certificate(req: GenCertificateReq) -> anyhow::Result<(Option<Vec<u8>>, V
 | 
			
		||||
    cert_builder.set_not_after(¬_after)?;
 | 
			
		||||
 | 
			
		||||
    // Specify CRL URL
 | 
			
		||||
    if let Some(issuer) = req.issuer
 | 
			
		||||
        && let Some(crl) = &issuer.crl
 | 
			
		||||
    {
 | 
			
		||||
        let crl_url = format!(
 | 
			
		||||
            "{}/pki/{}",
 | 
			
		||||
            AppConfig::get().unsecure_origin(),
 | 
			
		||||
            crl.file_name().unwrap().to_string_lossy()
 | 
			
		||||
        );
 | 
			
		||||
    if let Some(issuer) = req.issuer {
 | 
			
		||||
        if let Some(crl) = &issuer.crl {
 | 
			
		||||
            let crl_url = format!(
 | 
			
		||||
                "{}/pki/{}",
 | 
			
		||||
                AppConfig::get().unsecure_origin(),
 | 
			
		||||
                crl.file_name().unwrap().to_string_lossy()
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
        cert_builder.append_extension(CRLDistributionPointExt { url: crl_url }.as_extension()?)?;
 | 
			
		||||
            cert_builder
 | 
			
		||||
                .append_extension(CRLDistributionPointExt { url: crl_url }.as_extension()?)?;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // If cert is a CA or not
 | 
			
		||||
@@ -423,12 +424,12 @@ fn refresh_crl(d: &CertData, new_cert: Option<&X509>) -> anyhow::Result<()> {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Add old entries
 | 
			
		||||
        if let Some(old_crl) = old_crl
 | 
			
		||||
            && let Some(entries) = old_crl.get_revoked()
 | 
			
		||||
        {
 | 
			
		||||
            for entry in entries {
 | 
			
		||||
                if X509_CRL_add0_revoked(crl, X509_REVOKED_dup(entry.as_ptr())) == 0 {
 | 
			
		||||
                    return Err(PKIError::GenCRLError("X509_CRL_add0_revoked").into());
 | 
			
		||||
        if let Some(old_crl) = old_crl {
 | 
			
		||||
            if let Some(entries) = old_crl.get_revoked() {
 | 
			
		||||
                for entry in entries {
 | 
			
		||||
                    if X509_CRL_add0_revoked(crl, X509_REVOKED_dup(entry.as_ptr())) == 0 {
 | 
			
		||||
                        return Err(PKIError::GenCRLError("X509_CRL_add0_revoked").into());
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -155,11 +155,12 @@ pub async fn sync_device(body: web::Json<JWTRequest>, actor: WebEnergyActor) ->
 | 
			
		||||
    let mut available_update = None;
 | 
			
		||||
 | 
			
		||||
    // Check if the version is available
 | 
			
		||||
    if let Some(desired) = device.desired_version
 | 
			
		||||
        && claims.info.version < desired
 | 
			
		||||
        && ota_manager::update_exists(OTAPlatform::from_str(&claims.info.reference)?, &desired)?
 | 
			
		||||
    {
 | 
			
		||||
        available_update = Some(desired);
 | 
			
		||||
    if let Some(desired) = device.desired_version {
 | 
			
		||||
        if claims.info.version < desired
 | 
			
		||||
            && ota_manager::update_exists(OTAPlatform::from_str(&claims.info.reference)?, &desired)?
 | 
			
		||||
        {
 | 
			
		||||
            available_update = Some(desired);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Ok(HttpResponse::Ok().json(SyncResult {
 | 
			
		||||
 
 | 
			
		||||
@@ -123,17 +123,17 @@ pub async fn set_desired_version(
 | 
			
		||||
 | 
			
		||||
    for d in devices {
 | 
			
		||||
        // Filter per platform
 | 
			
		||||
        if let Some(p) = body.platform
 | 
			
		||||
            && d.info.reference != p.to_string()
 | 
			
		||||
        {
 | 
			
		||||
            continue;
 | 
			
		||||
        if let Some(p) = body.platform {
 | 
			
		||||
            if d.info.reference != p.to_string() {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Filter per device
 | 
			
		||||
        if let Some(ids) = &body.devices
 | 
			
		||||
            && !ids.contains(&d.id)
 | 
			
		||||
        {
 | 
			
		||||
            continue;
 | 
			
		||||
        if let Some(ids) = &body.devices {
 | 
			
		||||
            if !ids.contains(&d.id) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        actor
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user