Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
13.5
Statistic
FMM
Blog
Sets the file path for the certificate.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 2.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
curl | The CURL session handle. | $curl | |
Value | The file path to the certificate. | "/tmp/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 |
Returns "OK" on success.
See also SSLCERT option in CURL manual.
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; "https://gsxapiut.apple.com:443/gsx-ws/services/emea/asp")]
# 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.GetDebugMessages"; $curl)]
#Cleanup
Set Variable [$result; Value:MBS("CURL.Release"; $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; "https://gsxapi.apple.com/gsx-ws/services/emea/asp") ]
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.GetDebugMessages"; $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.Release") ]
Created 18th August 2014, last changed 25th June 2020