Add list development certs to dev session api

This commit is contained in:
nab138
2026-01-29 11:12:09 -05:00
parent f01fcc0ac0
commit c639ed2f2f
5 changed files with 60 additions and 6 deletions

13
Cargo.lock generated
View File

@@ -821,6 +821,7 @@ dependencies = [
"reqwest",
"rootcause",
"serde",
"serde_bytes",
"serde_json",
"sha2",
"thiserror 2.0.18",
@@ -1374,7 +1375,7 @@ dependencies = [
"security-framework",
"security-framework-sys",
"webpki-root-certs",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -1451,6 +1452,16 @@ dependencies = [
"serde_derive",
]
[[package]]
name = "serde_bytes"
version = "0.11.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8"
dependencies = [
"serde",
"serde_core",
]
[[package]]
name = "serde_core"
version = "1.0.228"

View File

@@ -5,8 +5,7 @@ use isideload::{
dev::developer_session::DeveloperSession,
};
use plist_macro::pretty_print_dictionary;
use tracing::{Level, debug};
use tracing::Level;
use tracing_subscriber::FmtSubscriber;
#[tokio::main]
@@ -60,7 +59,7 @@ async fn main() {
.expect("No developer teams available for this account");
let res = dev_session
.list_devices(team, None)
.list_all_development_certs(team, None)
.await
.expect("Failed to list developer devices");

View File

@@ -38,3 +38,4 @@ hmac = "0.12.1"
cbc = { version = "0.1.2", features = ["std"] }
aes = "0.8.4"
aes-gcm = "0.10.3"
serde_bytes = "0.11.19"

View File

@@ -14,7 +14,8 @@ use crate::{
dev::structures::{
DeveloperDevice,
DeveloperDeviceType::{self, *},
DeveloperTeam, ListDevicesResponse, ListTeamsResponse,
DeveloperTeam, DevelopmentCertificate, ListCertificatesResponse, ListDevicesResponse,
ListTeamsResponse,
},
util::plist::PlistDataExtract,
};
@@ -136,6 +137,30 @@ impl<'a> DeveloperSession<'a> {
Ok(response.devices)
}
pub async fn list_all_development_certs(
&self,
team: &DeveloperTeam,
device_type: impl Into<Option<DeveloperDeviceType>>,
) -> Result<Vec<DevelopmentCertificate>, Report> {
let body = plist!(dict {
"teamId": &team.team_id,
});
let response: ListCertificatesResponse = self
.send_developer_request(&dev_url("listAllDevelopmentCerts", device_type), body)
.await
.context("Failed to list development certificates")?;
if response.result_code != 0 {
warn!(
"Non-zero list development certs response code: {}",
response.result_code
)
};
Ok(response.certificates)
}
}
fn dev_url(endpoint: &str, device_type: impl Into<Option<DeveloperDeviceType>>) -> String {

View File

@@ -1,4 +1,5 @@
use serde::Deserialize;
use serde_bytes::ByteBuf;
#[derive(Debug, Clone)]
pub enum DeveloperDeviceType {
@@ -50,3 +51,20 @@ pub struct ListDevicesResponse {
pub devices: Vec<DeveloperDevice>,
pub result_code: i64,
}
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DevelopmentCertificate {
pub name: String,
pub certificate_id: String,
pub serial_number: Option<String>,
pub machine_id: Option<String>,
pub cert_content: Option<ByteBuf>,
}
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ListCertificatesResponse {
pub certificates: Vec<DevelopmentCertificate>,
pub result_code: i64,
}