Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides
New in version: 6.0   6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3    Statistic  


Sets the file path for the certificate.

Component: CURL
Version: 2.5
Mac OS X: Yes
Windows: Yes
Server: Yes
FileMaker Cloud: Yes

MBS( "CURL.SetOptionSSLCert"; Handle; Value { ; Encoding } )


Parameter Description Example value
Handle The CURL session handle. $curl
Value The file path to the certificate. "/tmp/test.pem"
Encoding Optional
The text encoding for text parameter.
Default is UTF-8.
Possible encoding names: ANSI, Arabic-Mac, Arabic-Win, Baltic-Win, CentralEurope-Mac, ChineseSimp-Mac, ChineseSimp-Win, ChineseTrad-Mac, ChineseTrad-Win, Cyrillic-Mac, Cyrillic-Win, EasternEurope-Win, Greek-Mac, Greek-Win, Hebrew-Mac, Hebrew-Win, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-15, Korean-Johab, Korean-Mac, Korean-Win, Latin1, Mac, Native, ShiftJIS-Mac, ShiftJIS-Win, Turkish-Mac, Turkish-Win, UTF-8, DOS or Windows. Pass native to use the native encoding of the current platform.


Returns "OK" on success.


Sets the file path for the certificate.
Pass a text string as parameter. The string should be the file name of your certificate. The default format is "PEM" and can be changed with CURL.SetOptionSSLCertType.

With NSS this can also be the nickname of the certificate you wish to authenticate with. If you want to use a file from the current directory, please precede it with "./" prefix, in order to avoid confusion with a nickname.


Set a client SSL certificate:

Set Variable [$r; Value:MBS("CURL.SetOptionSSLCert"; $curl; "/some/certfile.pem")]
Set Variable [$r; Value:MBS("CURL.SetOptionSSLCertType"; $curl; "PEM")]
Set Variable [$r; Value:MBS("CURL.SetOptionKeyPassword"; $curl; "secret")]

Send request to Apple's gsx webservice:

Set Variable [$XMLRequest; Value:""]
#Start new session
Set Variable [$curl; Value:MBS("CURL.New")]
# URL for web service
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "")]
# Mark content as XML
Set Variable [$result; Value:MBS("CURL.SetOptionHTTPHeader"; $curl; "Content-Type: text/xml; charset=UTF-8")]
# Pass XML content for request
Set Variable [$result; Value:MBS("CURL.SetOptionPostFields"; $curl; $XMLRequest)]
# Certificate and private key in one file
Set Variable [$result; Value:MBS("CURL.SetOptionSSLCert"; $curl; "/Users/cs/Keys/apple-cert+key.pem")]
# Root certificates
Set Variable [$result; Value:MBS("CURL.SetOptionCAINFO"; $curl; "/Users/cs/Keys/cacert.pem")]
# SSL Key is in PEM Format
Set Variable [$result; Value:MBS("CURL.SetOptionSSLCertType"; $curl; "PEM")]
# Password for key file
Set Variable [$result; Value:MBS("CURL.SetOptionKeyPassword"; $curl; "xxx")]
# SSL Verification on
Set Variable [$result; Value:MBS("CURL.SetOptionSSLVerifyPeer"; $curl; 1)]
Set Variable [$result; Value:MBS("CURL.SetOptionSSLVerifyHost"; $curl; 1)]
# use TLS v1.2
Set Variable [$result; Value:MBS("CURL.SetOptionSSLVersion"; $curl; 6)]
#RUN now
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
#Check result
Set Field [CURL Test::Text; MBS("CURL.GetResultAsText"; $curl; "UTF8")]
Set Field [CURL Test::debug; MBS("CURL.GetDebugAsText"; $curl)]
Set Variable [$result; Value:MBS("CURL.Cleanup"; $curl)]

Talk to Apple's global service exchange webservice:

# Various parameters
Set Variable [ $userid ; Value: "???" ]
Set Variable [ $serviceAccountNo ; Value: "???" ]
Set Variable [ $PrivateKeyPassword ; Value: "???" ]

# Build XML with our values:
Set Variable [ $xml ; Value: Tabelle::Login XML Template ]
Set Variable [ $xml ; Value: Substitute($xml; "$userid$"; MBS("Text.EncodeToXML"; $userid)) ]
Set Variable [ $xml ; Value: Substitute($xml; "$serviceAccountNo$"; MBS("Text.EncodeToXML"; $serviceAccountNo)) ]

# Start CURL
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionURL";$curl; "") ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionSSLCertType"; $curl; "PEM") ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionKeyPassword"; $curl; $PrivateKeyPassword) ]
# pem file with private key and certificate from Apple
Set Variable [ $r ; Value: MBS("CURL.SetOptionSSLCert"; $curl; "/Users/test/Desktop/test.pem") ]
# some root certificates
Set Variable [ $r ; Value: MBS("CURL.SetOptionCAINFO"; $curl; "/Users/test/Desktop/cacert.pem") ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionSSLVersion"; $curl; 6) // TLS v1.2 ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionTimeOut"; $curl; 10) ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionHTTPHeader"; $curl; "Content-Type: text/xml; charset=UTF-8") ]
# run the login query
Set Variable [ $r ; Value: MBS("CURL.Perform"; $curl) ]
# check result
Set Variable [ $httpResponse ; Value: MBS( "CURL.GetResponseCode"; $curl ) ]
Set Field [ Tabelle::CURL Result ; $r ]
Set Field [ Tabelle::CURL Input ; $xml ]
Set Field [ Tabelle::CURL Debug ; MBS("CURL.GetDebugAsText"; $curl; "UTF8") ]
Set Field [ Tabelle::CURL Output ; MBS("CURL.GetResultAsText"; $curl; "UTF8") ]
# here we extract session
Set Field [ Tabelle::SessionID ; MBS("Text.FindBetween"; Tabelle::CURL Output; "<userSessionId>"; "</userSessionId>") ]
Wenn [ $r = "OK" UND $httpResponse = 200 ]
        # OK
Ende (wenn)
Set Variable [ $r ; Value: MBS("CURL.Cleanup") ]

See also

CURL.SetOptionSSHPublicKeyfile   -   CURL.SetOptionSSLCertType

Feedback: Report problem or ask question.

MBS REALbasic Plugins - Christians Software aus Nickenich