mirror of
https://github.com/nab138/isideload.git
synced 2026-03-02 06:26:16 +01:00
Improve cert revocation prompt function
This commit is contained in:
@@ -9,6 +9,7 @@ use isideload::{
|
|||||||
teams::DeveloperTeam,
|
teams::DeveloperTeam,
|
||||||
},
|
},
|
||||||
sideload::{SideloaderBuilder, TeamSelection, builder::MaxCertsBehavior},
|
sideload::{SideloaderBuilder, TeamSelection, builder::MaxCertsBehavior},
|
||||||
|
util::keyring_storage::KeyringStorage,
|
||||||
};
|
};
|
||||||
|
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
@@ -111,20 +112,21 @@ async fn main() {
|
|||||||
Some(
|
Some(
|
||||||
selections
|
selections
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|n| certs[n - 1].clone())
|
.map(|n| certs[n - 1].serial_number.clone().unwrap_or_default())
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut sideloader = SideloaderBuilder::new(dev_session, apple_id.to_string())
|
let mut sideloader = SideloaderBuilder::new(dev_session, apple_id.to_string())
|
||||||
.team_selection(TeamSelection::PromptOnce(team_selection_prompt))
|
.team_selection(TeamSelection::PromptOnce(team_selection_prompt))
|
||||||
.max_certs_behavior(MaxCertsBehavior::Prompt(cert_selection_prompt))
|
.max_certs_behavior(MaxCertsBehavior::Prompt(Box::new(cert_selection_prompt)))
|
||||||
|
.storage(Box::new(KeyringStorage::new("minimal".to_string())))
|
||||||
.machine_name("isideload-minimal".to_string())
|
.machine_name("isideload-minimal".to_string())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let result = sideloader.install_app(&provider, app_path, true).await;
|
let result = sideloader.install_app(&provider, app_path, true).await;
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => println!("App installed successfully"),
|
Ok(_) => println!("App installed successfully"),
|
||||||
Err(e) => panic!("Failed to install app: {:?}", e),
|
Err(e) => panic!("{}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ pub enum SideloadError {
|
|||||||
#[error("Invalid bundle: {0}")]
|
#[error("Invalid bundle: {0}")]
|
||||||
InvalidBundle(String),
|
InvalidBundle(String),
|
||||||
|
|
||||||
#[error(transparent)]
|
#[error("{0}")]
|
||||||
IdeviceError(#[from] IdeviceError),
|
IdeviceError(#[from] IdeviceError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ pub enum MaxCertsBehavior {
|
|||||||
/// If the maximum number of certificates is reached, return an error instead of creating a new certificate
|
/// If the maximum number of certificates is reached, return an error instead of creating a new certificate
|
||||||
Error,
|
Error,
|
||||||
/// If the maximum number of certificates is reached, prompt the user to select which certificates to revoke until it is possible to create a new certificate
|
/// If the maximum number of certificates is reached, prompt the user to select which certificates to revoke until it is possible to create a new certificate
|
||||||
Prompt(fn(&Vec<DevelopmentCertificate>) -> Option<Vec<DevelopmentCertificate>>),
|
Prompt(Box<dyn Fn(&Vec<DevelopmentCertificate>) -> Option<Vec<String>> + Send + Sync>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The actual behavior choices for extensions (non-prompt variants)
|
/// The actual behavior choices for extensions (non-prompt variants)
|
||||||
|
|||||||
@@ -307,17 +307,12 @@ impl CertificateIdentity {
|
|||||||
error!("User did not select any certificates to revoke");
|
error!("User did not select any certificates to revoke");
|
||||||
return Err(error.into());
|
return Err(error.into());
|
||||||
}
|
}
|
||||||
for cert in certs_to_revoke.unwrap() {
|
for serial in certs_to_revoke.unwrap() {
|
||||||
info!(
|
info!("Revoking certificate with serial number: {}", serial);
|
||||||
"Revoking certificate with name: {}",
|
|
||||||
cert.machine_name
|
|
||||||
.unwrap_or(cert.machine_id.unwrap_or_default())
|
|
||||||
);
|
|
||||||
let serial_number = cert.serial_number.clone();
|
|
||||||
developer_session
|
developer_session
|
||||||
.revoke_development_cert(team, &cert.serial_number.unwrap(), None)
|
.revoke_development_cert(team, &serial, None)
|
||||||
.await?;
|
.await?;
|
||||||
existing_certs.retain(|c| c.serial_number != serial_number);
|
existing_certs.retain(|c| c.serial_number != Some(serial.clone()));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,10 +210,10 @@ impl Sideloader {
|
|||||||
.await
|
.await
|
||||||
.context("Failed to install app on device")?;
|
.context("Failed to install app on device")?;
|
||||||
|
|
||||||
if self.delete_app_after_install {
|
if self.delete_app_after_install
|
||||||
if let Err(e) = tokio::fs::remove_dir_all(signed_app_path).await {
|
&& let Err(e) = tokio::fs::remove_dir_all(signed_app_path).await
|
||||||
|
{
|
||||||
tracing::warn!("Failed to remove temporary signed app file: {}", e);
|
tracing::warn!("Failed to remove temporary signed app file: {}", e);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(special_app)
|
Ok(special_app)
|
||||||
|
|||||||
Reference in New Issue
Block a user