Skip to content

codesigning: error when parsing smartcard xmlΒ #2753

@jagobagascon

Description

@jagobagascon

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:

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

system_profiler SPSmartCardsDataType -xml

Returns an expiration with the value 'N/A':

<dict>
	<key>#01</key>
	<string>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
	</string>
	<key>_name</key>
	<string>com.apple.platformsso:BBBBBBBBBBB</string>
</dict>

And when the python script tries to parse it, it simply fails:

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions