ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Certificate functions
  • LDAP section of the certificate
  • Managing certificates in WEBDEV
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Checks the correspondence between a signature and a string.
Example
WINDEVReports and QueriesUser code (UMC)
MyCertificate is Certificate
 
// Open the certificate picker of Windows
MyCertificate = CertificateSelect()
 
// Cancellation or error
IF MyCertificate.Name = "" THEN
RETURN
END
 
// Checks whether the selected certificate is valid for signing
IF MyCertificate.ValidForSignature = False THEN
Info("The selected certificate cannot be used to generate a signature.")
RETURN
END
 
// Retrieve the buffer containing the signature
bufSignature is Buffer
bufSignature = CertificateSignString("Character string to sign", MyCertificate)
 
// Check the signature
SWITCH CertificateCheckString("Character string to sign", bufSignature)
CASE certificateOk: Info("Valid signature and trusted certificate")
CASE certificateInvalid: Info("Invalid signature or certificate")
CASE certificateExpired: Info("Valid signature but expired certificate")
CASE certificateUntrusted: Info("Valid signature but root confidence " + ...
"of certificate not reliable")
END
WINDEVWEBDEV - Server codeWindowsLinuxAndroidiPhone/iPad
// Check the signature of data transmitted by PayBox
sData is string = [
act=ps_validated&secid=190&fpay=1&montant=25000&reference=CMD2019021309341242&auto=XXXXXX
&trans=33015345&abo=0&paiement=CARTE&carte=Maestro
&idtrans=14515770&erreur=00000&payscarte=FRA&fincb=44&debcb=111122
]
sSignatureBase64 is string = [
DVD+nMNaQatCBdS/qVjZGE8DtwPvIA3jxGhKlU83MyYC98ezKori/
3cceClqNhtmzD6MDhuKbm8Lw5sFTYdaKWzy79tXzxMLCq814u0+fc5KSihExS6
gIaixjCHiOTgqQXmPP29MkFPpfAFz/wKU/fu+FPGp2dpgLcoRAv0+m1o=
]
sPublicKeyFile is string = fDataDir() + "\pubkey.pem"
// Signature Base64 decoding
bufSignature is Buffer = Décode(Replace(sSignatureBase64, CR, ""), encodeBASE64URL)
// SHA-1 digest ==> certSHA160
IF CertificateCheckString(sData, bufSignature, sPublicKeyFile,
"", "", certSignatureOnly + certSHA160) = certificateOk THEN
Info("The signature is correct")
ELSE
Error("The signature is incorrect", ErrorInfo())
END
Syntax
WINDEVWEBDEV - Server codeReports and QueriesLinuxUser code (UMC)

Checking the correspondence between a signature and a string Hide the details

<Result> = CertificateCheckString(<String to check> , <Signature buffer>)
<Result>: Integer constant
Result of signature check:
certificateExpiredValid signature but expired certificate.
certificateInvalidInvalid signature or certificate.
certificateOkTrusted signature and certificate.
certificateUntrustedValid signature but untrusted certificate root.
<String to check>: Character string
Character string on which the check will be performed.
<Signature buffer>: Buffer
Buffer containing the signature of the string. This buffer is returned by CertificateSignString.

Checking the correspondence between a signature and a string (numeric signature) Hide the details

<Result> = CertificateCheckString(<String to check> , <Signature buffer> , <Certificate file> [, <Password> [, <Trusted authorities>]] , <Options>)
<Result>: Integer constant
Result of signature check:
certificateExpiredValid signature but expired certificate.
certificateInvalidInvalid signature or certificate.
certificateOkTrusted signature and certificate.
certificateUntrustedValid signature but untrusted certificate root.
<String to check>: Character string or Buffer
Character string on which the check will be performed.
This parameter can correspond to an ANSI string, a UNICODE string or a Buffer. The string will be processed as a buffer.
If this parameter corresponds to a string (without specifying the type), the type of string taken into account depends on the type of string defined by default in the current project configuration.
Remark: In the case of a UNICODE string, note that Unicode is not the same on Linux and Windows.
<Signature buffer>: Buffer
Buffer containing the signature of the string. This buffer is returned by CertificateSignString.
<Certificate file>: Character string or Buffer
Corresponds to:
  • Full path of certificate file to use (in PEM, DER or P12 format).
  • Buffer containing the certificate to use.
Remarks:
  • For a PKCS7 signature, this parameter allows you to add certificates used to search for the trusted string.
  • For the raw signature, this parameter contains the public key.
<Password>: Character string
Password that will be used to decrypt the certificate file if this one is password-protected.
Remark: This parameter is useful if the certificate used is identical to the one used for the signature.
<Trusted authorities>: String or array of strings
Full path of trusted certificate to use.
This parameter can also correspond to an array of strings containing the full path of different trusted certificates to use.
Remark: The trusted certificates added with TrustedCertificateAdd are also taken into account.
AndroidAndroid Widget Caution: This parameter is required in the recent systems (Android 2.6 and later).
<Options>: Integer constant (or combination of constants)
Signature format:
certPKCS7Signature in PKCS7 format.
certSignatureOnlySignature only. In this case, the certSignatureOnly constant must be combined with the hashing algorithm:
  • certSignatureOnly + certMD5: MD5 algorithm.
  • certSignatureOnly + certSHA160: SHA1 algorithm.
  • certSignatureOnly + certSHA256: SHA2 algorithm. A 256-bit result is produced.
  • certSignatureOnly + certSHA384: SHA-384 algorithm. A 384-bit result is produced
  • certSignatureOnly + certSHA512: SHA-512 algorithm. A 512-bit result is produced.
In this case, the trusted string is not checked. Only the validity of signature in relation to the public key is checked.
Remarks

LDAP section of the certificate

The certificate and the trusted certificate must have different LDAP sections. A section contains the details about the issuer of the certificate. For example, you can use different "commonName" sub-sections.
Otherwise, the function may return an error corresponding to the certificateUntrusted constant.
Remark: Depending on the tool used, this section can have different names: Issuer (Windows certificate), etc.
WEBDEV - Server code

Managing certificates in WEBDEV

In order for the certificates to be visible to the site user, they must be installed on the server in the store of custom certificates of the Internet user.
Business / UI classification: Business Logic
Component: wd290std.dll
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/05/2023

Send a report | Local help