Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mime
integer n
integer i
string ls_SigningTime

li_Success = 0

loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
if li_rc < 0 then
    destroy loo_Mime
    MessageBox("Error","Connecting to COM object failed")
    return
end if
li_Success = loo_Mime.LoadMimeFile("qa_data/signed.eml")
if li_Success = 0 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Mime
    return
end if

//  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.
li_Success = loo_Mime.Verify()
if li_Success <> 1 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Mime
    return
end if

n = loo_Mime.NumSignerCerts

for i = 0 to n - 1
    //  Only signers that included a signing time have one to retrieve.
    if loo_Mime.HasSignatureSigningTime(i) then
        ls_SigningTime = loo_Mime.GetSignatureSigningTimeStr(i)
        if loo_Mime.LastMethodSuccess = 0 then
            Write-Debug loo_Mime.LastErrorText
            destroy loo_Mime
            return
        end if

        Write-Debug "Signer " + string(i) + " signing time: " + ls_SigningTime
    end if

next


destroy loo_Mime