kornelski / kornelski/rust-security-framework

Panics with a cert with an empty subject name

Open Beginner friendly
#259 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
304
Forks
105
PR merge metrics
No merged PRs in 30d

Description

I'm seeing some users have a SCEP certificate which have no subject name. Here's a cert that matches nearly exactly a real certificate I'm seeing the crashes on:

[client-cert-no-subject.der.zip](https://github.com/user-attachments/files/32390693/client-cert-no-subject.der.zip)

With code like this:

```rust
pub fn certificate_with_no_subject_name() -> SecCertificate {
let certificate = include_bytes!("../test/client-cert-no-subject.der");
p!(SecCertificate::from_der(certificate))
}

#[test]
fn subject_summary_with_null_subject() {
let cert = certificate_with_no_subject_name();
assert_eq!("", cert.subject_summary());
}
```

The panic looks like this:

```
panicked at /Users/grahamc/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/core-foundation-0.10.1/src/string.rs:28:1:
Attempted to create a NULL object.
```

I'm also getting a panic having to do with `ItemSearchOptions`, but I haven't nailed it down yet, because keychain doesn't seem to let _me_ import this cert.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start from SecCertificate::subject_summary and the subject_summary_with_null_subject test, using the attached client-cert-no-subject.der fixture or the include_bytes! example as the reproduction. Verify the certificate with an empty subject no longer panics and that subject_summary returns an empty string; run the focused test to confirm the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, rust
Domain
security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.