ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Certificate functions
  • LDAP section of the certificate
  • Managing certificates in WEBDEV
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
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 reliable certificate")
	CASE certificateInvalid: Info("Invalid signature or certificate")
	CASE certificateExpired: Info("Valid signature but certificate expired")
	CASE certificateUntrusted: Info("Valid signature but trusted root" + ...
		"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 = Decode(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 of 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 of which the check will be performed.
This parameter can be 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.
Note: In the case of a Unicode string, please note that Unicode is not the same under Linux as it is under 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 or Secret string
Password that will be used to decrypt the certificate file if this one is password-protected.
Note: This parameter is particularly useful if the certificate used is identical to the one used for signing.

New in version 2025
Secret strings: If you use the secret string vault, the type of secret string used for this parameter must be "Ansi or Unicode string".
To learn more about secret strings and how to use the vault, see Secret string vault.
<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.
Note: Trusted certificates added with the TrustedCertificateAdd function are also taken into account.
AndroidAndroid Widget Note: This setting is required for recent systems (Android 2.6 or higher)..
<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:
  • certSignatureSeule + certMD5: MD5 algorithm.
  • certSignatureSeule + certSHA160: SHA1 algorithm.
  • certSignatureSeule + certSHA256: SHA2 algorithm. A 256-bit result is produced.
  • certSignatureSeule + certSHA384: SHA-384 algorithm. A 384-bit result is produced
  • certSignatureSeule + 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.
Note: Depending on the tool used, this section may have different names: Issuer (Windows certificate), ...
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: wd300std.dll
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 02/14/2025

Send a report | Local help