PureBasic
PureBasic
Get an S/MIME Signing Time
See more MIME Examples
Demonstrates the Chilkat Mime.GetSignatureSigningTimeStr method, which returns the CMS signingTime attribute for the signer at a zero-based index, as an RFC 822-style date string in GMT. The only argument is the signer index.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: This is the timestamp the signer asserted at signing — useful for "when was this signed" audit trails and for evaluating whether the signing certificate was valid at that moment. Because it is a signed attribute, it is tamper-evident. Guard the call with
HasSignatureSigningTime, since the attribute is optional. Note it is the signer's claim, not a trusted third-party timestamp.Chilkat PureBasic Downloads
IncludeFile "CkMime.pb"
Procedure ChilkatExample()
success.i = 0
mime.i = CkMime::ckCreate()
If mime.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkMime::ckLoadMimeFile(mime,"qa_data/signed.eml")
If success = 0
Debug CkMime::ckLastErrorText(mime)
CkMime::ckDispose(mime)
ProcedureReturn
EndIf
; After verifying, get the CMS signingTime for each signer that has one, as an RFC 822 date string
; in GMT. The only argument is the zero-based signer index.
success = CkMime::ckVerify(mime)
If success <> 1
Debug CkMime::ckLastErrorText(mime)
CkMime::ckDispose(mime)
ProcedureReturn
EndIf
n.i = CkMime::ckNumSignerCerts(mime)
i.i
For i = 0 To n - 1
; Only signers that included a signing time have one to retrieve.
If CkMime::ckHasSignatureSigningTime(mime,i)
signingTime.s = CkMime::ckGetSignatureSigningTimeStr(mime,i)
If CkMime::ckLastMethodSuccess(mime) = 0
Debug CkMime::ckLastErrorText(mime)
CkMime::ckDispose(mime)
ProcedureReturn
EndIf
Debug "Signer " + Str(i) + " signing time: " + signingTime
EndIf
Next
CkMime::ckDispose(mime)
ProcedureReturn
EndProcedure