Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

CURL.SetOptionCAInfo

Sets a path to find certificate file.

Component Version macOS Windows Linux Server iOS SDK
CURL 2.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "CURL.SetOptionCAInfo"; curl; Value { ; Encoding } )   More

Parameters

Parameter Description Example Flags
curl The CURL session handle. $curl
Value The file path for the certificates. "/test.pem"
Encoding The text encoding for text parameter.
Default is UTF-8.
Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the FAQ.
"UTF8" Optional

Result

Returns "OK" on success.

Description

Sets a path to find certificate file.
Pass a string naming a file holding one or more certificates to verify the peer with. This makes sense only when used in combination with the CURL.SetOptionVerifyPeer option. If CURL.SetOptionVerifyPeer is zero, CURL.SetOptionCAInfo need not even indicate an accessible file.

This option is by default set to the system path where libCURL's cacert bundle is assumed to be stored, as established at build time.

When built against NSS, this is the directory that the NSS certificate database resides in.

see also
http://www.mbsplugins.de/archive/2013-01-31/SSL_Security_with_CURL/monkeybreadsoftware_blog_archive

Starting with version 8.0 the plugin will always use UTF-8 encoding for file path on Linux and macOS. For macOS we also do the unicode character normalization for file names for you.

See also CAINFO option in CURL manual.

Examples

Enables verification and uses cacert.pem file for certificates:

MBS( "CURL.SetOptionCAInfo"; $curl; $cacertPath )
MBS( "CURL.SetOptionSSLVerifyHost"; $curl; 2 )
MBS( "CURL.SetOptionSSLVerifyPeer"; $curl; 1 )

Use FileMaker's root file in CURL:

Set Variable [ $curl ; Value: MBS("CURL.New") ] 

If [ MBS("IsIOS") ] 
    # look for path to certificate file
    Set Variable [ $path ; Value: Substitute(MBS("Folders.UserDocuments"); "/Documents"; "/Library/Application Support/FileMaker/iOS/1.0/root.pem") ] 
    If [ MBS("Files.FileExists"; $path) ] 
        # use in CURL
        Set Variable [ $r ; Value: MBS( "CURL.SetOptionCAINFO"; $curl; $path) ] 
    Else
        Show Custom Dialog [ "File not found." ; $path
    End If
Else If [ MBS("IsMacOSX") ] 
    # look for path to certificate file
    Set Variable [ $path ; Value: Substitute(MBS("Folders.UserDocuments"); "/Documents"; "/Library/Application Support/FileMaker/Shared/17.0/root.pem") ] 
    If [ MBS("Files.FileExists"; $path) ] 
        # use in CURL
        Set Variable [ $r ; Value: MBS( "CURL.SetOptionCAINFO"; $curl; $path) ] 
    Else
        Show Custom Dialog [ "File not found." ; $path
    End If
Else If [ MBS("IsWindows") ] 
    # look for path to certificate file
    Set Variable [ $path ; Value: Substitute(MBS("Folders.UserDocuments"); "\Documents"; "\AppData\Local\FileMaker\FileMaker Pro Advanced\17.0\root.pem") ] 
    If [ MBS("Files.FileExists"; $path) ] 
        # use in CURL
        Set Variable [ $r ; Value: MBS( "CURL.SetOptionCAINFO"; $curl; $path) ] 
    Else
        Show Custom Dialog [ "File not found." ; $path
    End If
Else If [ MBS("IsLinux") ] 
    # look for path to certificate file
    Set Variable [ $path ; Value: "/FileMakerData/Extensions/OpenSSL/root.pem" ] 
    # use in CURL
    Set Variable [ $r ; Value: MBS( "CURL.SetOptionCAINFO"; $curl; $path) ] 
End If

See also

Release notes

Example Databases

Blog Entries

Created 18th August 2014, last changed 26th May 2021


CURL.SetOptionCACacheTimeout - CURL.SetOptionCAInfoBlob