bazelbuild / bazelbuild/rules_apple
codesigning: error when parsing smartcard xml
- Dominant language
- Starlark
- Stars
- 593
- Forks
- 334
- Avg merge
- 16h 48m
- Merged PRs (30d)
- 9
Description
### Error
The codesigning tool is throwing an error when running an iOS app on Mac devices with an identity provider (IdP).
The error returned is this:
```log
ValueError: time data 'N/A' does not match format '%Y-%m-%d %H:%M:%S %z'
```
### Cause
The error happens because these devices include a key without an expiration date in their keychain, so the following command
```bash
system_profiler SPSmartCardsDataType -xml
```
Returns an expiration with the value 'N/A':
```xml
#01
Kind: private ECDSA 256-bit, Certificate: no, Usage: Derive Decrypt Unwrap
Valid from: N/A to: N/A, SSL trust: N/A, X509 trust: N/A
_name
com.apple.platformsso:BBBBBBBBBBB
```
And when the python script tries to parse it, it simply fails:
```py
expiry_date = re.search(r"(?<=to:)(.*?)(?=,)", data, re.DOTALL).group().strip()
expiry_date = datetime.datetime.strptime(expiry_date, "%Y-%m-%d %H:%M:%S %z")
```
Contributor guide
Research direction
Start from the Python parsing snippet in the issue and trace the code that reads the smartcard XML output. Verify handling for an expiration value of 'N/A' while preserving normal date parsing, then confirm the codesigning command no longer raises this error for the shown keychain entry.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, macos, python
- Domain
- build-system, mobile-dev, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100