Twilio Verify API verification call return curl error - twilio-api

I am now trying out the Twilio Verify API and the guides actually showed there are only two calls to the API to send the OTP to the target phone number and check if the OTP entered by end user is correct or not. I have problem with the verify code part, which return the curl error.
The OTP is successfully sent to the target phone.
This is the curl command i used to check the OTP:
curl -GET 'https://api.authy.com/protected/json/phones/verification/check' -d api_key=xxxx -d verification_code=xxxx-d phone_number=xx-d country_code=xx
This is the error message:
curl: (58) could not load PEM client certificate, OpenSSL error error:02001002:system library:fopen:No such file or directory, (no key found, wrong pass phrase, or wrong file format?)

Sorry for not reading the error message properly, I fixed it already by add the SSL cert path and private key path of the server to the curl command and it works.
curl -GET 'https://api.authy.com/protected/json/phones/verification/check' -d api_key=xxxx -d verification_code=xxxx-d phone_number=xx-d country_code=xx --cert path/to/fullchain.pem --key path/to/privkey.pem

Related

curl Failed to import cert file client.crt on command prompt and Powershell works fine on gitbash

I am using Windows...
When I run the following curl command through gitbash it works fine:
curl --cacert ca.crt --key client.key --cert client.crt "https://myurl"
However, if I try to run the same command in command prompt or Powershell, I get this error:
curl: (58) schannel: Failed to import cert file client.crt, last error is 0x80092002
What do I need to do to get the command working in Command Prompt or Powershell?
Windows version of curl.exe is not configured to work with openssl but git's is.
So to make sure whenever I typed 'curl' into a command prompt, it was using git's version of curl I added the path to git's curl (C:\Program Files\Git\mingw64\bin) in system environment variables and moved it right to the top…so it find’s git’s curl before it finds window’s curl.
After then restarted the command prompt it resolved the issue.
You are providing your client certificate in the wrong format. curl requires the certificate in the PEM format (source):
-E/--cert <certificate[:password]>
(SSL) Tells curl to use the specified certificate file when getting a file with
HTTPS or FTPS. The certificate must be in PEM format. If the optional password
isn't specified, it will be queried for on the terminal. Note that this option
assumes a "certificate" file that is the private key and the private
certificate concatenated! See --cert and --key to specify them independently.
If curl is built against the NSS SSL library then this option can tell curl the
nickname of the certificate to use within the NSS database defined by the
environment variable SSL_DIR (or by default /etc/pki/nssdb). If the NSS PEM
PKCS#11 module (libnsspem.so) is available then PEM files may be loaded. If you
want to use a file from the current directory, please precede it with "./"
prefix, in order to avoid confusion with a nickname.
If this option is used several times, the last one will be used.
Your certificate might be in the DER format or contain a whole certificate chain instead of your single client certificate.
in the manpage of curl, it is described that on Windows, it uses schannel provider by default (which itself uses the windows store). I am on the same errand now :-) trying to find a way to pass the certs from the command line and from local files.
Perhaps try importing the certs into the Windows store.
On our Windows 2019 server we have two curl.exe.
By default, the version 7.83.1 was summoned.
The issue was solved by using the version 7.54.1 and adding the full path to access it.

Serve sstate-cache with basic auth

I'm trying to serve a Yocto cache to the internet and I want to password-protect the share with basic authentication.
This works:
$ curl http://foo:bla#localhost:8081/build/old-sstate-cache/ # OK!
$ curl -u foo:bla http://localhost:8081/build/old-sstate-cache/ # OK!
However, when building Yocto, it doesn't. Here is my local.conf:
SSTATE_MIRRORS ?= "file://.* http://localhost:8081/build/old-sstate-cache/PATH;user=foo:bla"
Looking at the server logs it says 401 (Unauthorized).
Is the syntax for basic auth in the url correct for building?

Sending mail with curl on Windows via MS Exchange Server

I am trying to send an email using curl on Windows 10 through an MS Exchange Server. The email is sent to another user in the same Active Directory domain, and the user who is sending the email is already authenticated under Windows.
Given the above, I can successfully send an email using telnet as follows:
or PowerShell as follows:
Given that the above two commands work, I am looking for the equivalent curl command. I have looked at the following SO answer:
Using curl to send email
and tried the following command (and many other combinations of options), but with no success.
curl -v --url "webmail.jXs.com:25" --mail-from "r#jXs.com" --mail-rcpt "s#jXs.com" --upload-file mail.txt
I get the following output:
where the mail.txt file is:
So, what is wrong with my curl command? Thanks.
Apparently when using curl, we have to specify the smtp communication protocol in the url (which is not necessary when using telnet or powershell). So, adding smtp:// to the url made the curl command work.
curl -v --url "smtp://webmail.jXs.com:25" --mail-from "r#jXs.com" --mail-rcpt "s#jXs.com" --upload-file mail.txt

Invoking IBM Cloud Functions with curl results in ""The supplied authentication is invalid"

I created a hello world action, could invoke it in the browser.
Invoking with curl and using the API key provided resulted in an error:
$ curl -u API-KEY -X POST https://us-south.functions.cloud.ibm.com/api/v1/namespaces/jps_LMI/actions/HelloWorld?blocking=true
{"code":"cd01b7ea690a0454ef05016daa917bd3","error":"The supplied authentication is invalid"}
Calling the unprotected request is working fine:
https://us-south.functions.cloud.ibm.com/api/v1/web/jps_LMI/default/HelloWorld.json

Bluemix Connection Refused: not authorised, can't register device

I have read several tutorials and topics and I did everything as described, but still I am not able to register device.
I have been trying to use MQTTlens and mosquitto but same problem, not authorised
Bellow is command for mosquitto
mosquitto_pub -h xwc8vm.messaging.internetofthings.ibmcloud.com -u use-token-auth -P 'YpSP?P98Wwe0pYGXPj' -i 'd:xwc8vm:devicetype:mydevice' -t /iot/x -m '{"d":"heloo"}'
This are devices data
Organization ID xwc8vm
Device Type devicetype
Device ID mydevice
Authentication Method token
Authentication Token XXXXXXXXXX
I have used host
xwc8vm.messaging.internetofthings.ibmcloud.com
and client
d:xwc8vm:devicetype:mydevice
I even tried using http://mqtt-helper.mybluemix.net/?cm_sp=dw-bluemix--nospace--answers, but got this error
(23:42:45.044)Failed to connect to xwc8vm.messaging.internetofthings.ibmcloud.com:1883. Code: 1, Message: AMQJSC0001E Connect timed out.
Everything is configured as here http://heidloff.net/article/useful-mqtt-tools-ibm-watson-iot-bluemix?cm_mc_uid=27677244132415055778021&cm_mc_sid_50200000=1505944109
You can check your TLS security setting in your dashboard under the security tab. New IoT services by default require TLS. If you are not using TLS then try setting it to optional to see if that resolves the problem.
The mosquito command is not complete, you need to specify the port 8883, and the connection is secure by default and you need to specify the server certificate that can be downloaded from below:
https://github.com/ibm-watson-iot/iot-python/blob/master/src/ibmiotf/messaging.pem
So the command should look like:
mosquitto_pub -h xwc8vm.messaging.internetofthings.ibmcloud.com -p 8883 -u "use-token-auth" -P "xxxxxxxxx" -i "d:xwc8vm:device-type:my-device" -t "iot-2/evt/x/fmt/json" -m {"d":"hello"} --cafile messaging.pem -d
messaging.pem file needs to be in the same location as mosquitto_pub file or you can pass the path to it
Note: Please mind the topic format:
"iot-2/evt/x/fmt/json" >>>>> iot-2/evt/event/fmt/event_format
Very important, please edit your post and remove or mask the authentication token