HOW-TO Use CURL and - s3-eu-west-1.amazonaws.com · Installing MC Client certificate in Windows...
Transcript of HOW-TO Use CURL and - s3-eu-west-1.amazonaws.com · Installing MC Client certificate in Windows...
HOW-TO Use CURL and SWAGGER
Version Date Sign Description
1.0 2019-03-26 MO
This HOW-TO explains how to use SWAGGER files and CURL for REST service call
HOW-TO use CURL and SWAGGER
• CURL
• SWAGGER
• Convert to pm12
API tests
This HOW-TO describes the use of swagger file to test REST interface
Windows browserInstalling MC Root certificate in Windows BrowserThe root certificate will tell the browser that the exchanged certificates for SSL is trusted
• Get the correct root certificate from MCP• (OBS! different root certificates for PRODUCTION and STAGING environment)
http://developers.maritimeconnectivity.net/identity/index.html#get-mcp-root-certificate• Download the Windows file• Install the Root Certificate (open the mc-ca-certs.cer file)
• Select Certificate store ”Trusted Root Certification Authorities”
Windows browserInstalling MC Client certificate in Windows BrowserThe client certificate will be used for authentication to the accessed service
• Issue a client certificate from MCP (service certificate with correct domain name)• Download the certificate including the private key (must be done immediately after issuing)
• Convert the files into .p12 files
• Install the Client Certificate (open the .p12 file)• Select default storage and finalise
API tests
SMA VIS instance can be tested with a browser
https://smavistest.stmvalidation.eu/swagger (public VIS SeaSWIM side)
On Windows
• Converting certificate from PEM to p12
• Download OpenSSL into local folderIssue a Certificate from the MC Portal and download the certificate
• Unpack the Certificate, there should be three (3) files• Run cmd and go to the OpenSSL folder• Run command ‘set RANDFILE=.rnd’• Run command ’openssl pkcs12 -export -in Your_Certificate_file.pem -inkey
Your_PrivateKey_file.pem -certfile mc-ca-chain.pem -name "Your_certificate_name" -out Your_certificate_output_filename.p12’
• Select password
You should know have a .p12 file that can be installed in a windows browser which allows you to be authenticated towards a SeaSWIM Connector.
curl
• Download curl– E.g. https://curl.haxx.se/download.html
– https://bintray.com/artifact/download/vszakats/generic/curl-7.53.1-win64-mingw.7z
• Download MC Root Certificate– http://developers.maritimecloud.net/identity/index.html
• Download Client Certificate– MC Portal
– Issue relevant certificate and download certificate
curlFor Windows; Adjust the client certificate
Convert the .pem certificate to .p12
• See HOW-TO Convert PEM to P12– set RANDFILE=.rnd
– openssl pkcs12 -export -in certificate.pem -inkey privkey.pem -certfile mc-ca-chain.pem -name "Your_certificate_name" -out key.p12
Convert the .p12 back to .pem
• openssl pkcs12 –in key.p12 –out key.pem -clcerts
curlExample of curls to VIS
curl --cert Mikael.pem --cacert mc-ca-chain.pem --header Accept:application/json --http1.1 -X GET "https://stmvistest.cloudapp.net/SMA009/V2/voyagePlans"
curl --cert Mikael.pem --cacert mc-ca-chain.pem --header Accept:application/json --header Content-Type:application/json --http1.1 -X GET https://stmvistest.cloudapp.net/SMA009/V2/voyagePlans --data “”
curl --cert Mikael.pem --cacert mc-ca-chain.pem --header Content-Type:text/xml --http1.1 -X POST https://stmvistest.cloudapp.net/SMA009/V2/voyagePlans" -T TestData/RTZ10.xml