Posts

Showing posts with the label curl

Check rabbitmq user's credential

This is pretty helpful when you want to check if the user's password of rabbitmq is correct: $ curl -i -u <theuser>:<thepassword> http://<rabitmq-host>:15672/api/whoami

How to list all the images on a Docker Registry

Pretty easy: * Normally with a insecure private Docker Registry you would do: curl http://<the domain>:<the port if not 80, usually it's 5000>/v2/_catalog * In a secure private Docker Registry: curl https://<user_name>:<password>@<the domain>/v2/_catalog The result will be something like: {"repositories":["anda/centos-source-aodh-api","anda/centos-source-aodh-base","anda/centos-source-aodh-evaluator","anda/centos-source-aodh-expirer","anda/centos-source-aodh-listener","anda/centos-source-aodh-notifier","anda/centos-source-barbican-api","anda/centos-source-barbican-base","anda/centos-source-barbican-keystone-listener","anda/centos-source-barbican-worker","anda/centos-source-base","anda/centos-source-bifrost-base","anda/centos-source-bifrost-deploy","anda/centos-source-blazar-api","anda/cen...

How to fix "/usr/local/lib/libldap_r-2.4.so.2: no version information available" error

When I ran "sudo apt update" this morning these errors showed up: /usr/lib/apt/methods/https: /usr/local/lib/libldap_r-2.4.so.2: no version information available (required by /usr/lib/x86_64-linux-gnu/libcurl-gnutls.s o.4) /usr/lib/apt/methods/https: /usr/local/lib/liblber-2.4.so.2: no version information available (required by /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so. 4) This error means libcurl was compiled with a version of libldap_r other than what I have in /usr/local/lib. So a work around is to symlink the missing files: sudo ln -fs /usr/lib/liblber-2.4.so.2 /usr/local/lib/  sudo ln -fs /usr/lib/libldap_r-2.4.so.2 /usr/local/lib/

Redmine - 500 error when upload files

For couple years, users could not upload files into our Redmine instance when creating or updating issues (or tickets). We ignored it because most of the tickets were created from the email pulling task (IMAP) and the attachments were created just fine. But when we developed an external tool to manipulate issues with attachment, I think it's time to seriously looking at the problem and fix it. Here is the command we try (upload file using Redmine's Rest API): # curl 'http://myredmine.com/uploads.json' -X POST -H 'X-Redmine-API-Key: <myapikey>' -H 'Content-Type: application/octet-stream' --data-binary "@myfile.png" and errors (/var/log/redmine/default/production.log): ... Completed 500 Internal Server Error in 15.4ms Errno::EACCES (Permission denied - /var/lib/redmine/default/files/2016/12):   app/models/attachment.rb:108:in `files_to_final_location'   app/controllers/attachments_controller.rb:88:in `upload' ... Rea...

Parent Single Log-In with PowerSchool - Part I

Image
Part I - Overview, Create or Update PowerSchool Parent accounts using PHP cURL Earlier this year I had a chance to work on a project which is creating a Single Log-In system for Parents using the PowerSchool data. Unlike other kind of users in PowerSchool (Students, Teacher) Parents cannot be bind to an Active Directory server (Yes, my life would be easier if they support LDAP for Parent accounts!), they are stored in a separate place in the database. After searching around for a while, I recognized that the only way for me to build a Single Log-In system for Parents is using the PowerSchool API and implement the SAML 2.0 protocol. The purpose of PowerSchool supporting this protocol is for developers to create a Single Sign-On layer for customized apps to use PowerSchool as an Identity Provider . To learn the PowerSchool API and to implement the SAML protocol which I never heard before is not a big deal to me as a developer, but in the limited amount of time, I was not sure i...

PHP cURL with HTTPS

When using PHP cURL against a SSL powered website, you need to add this line (the red one) before calling curl_exec: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://my.domain.com'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_COOKIEFILE, 'mycookie.txt'); curl_setopt($ch, CURLOPT_COOKIEJAR, 'mycookie.txt'); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $buffer = curl_exec($ch); (Notes that this is just a workaround, for proper fix please read this article: http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/ )

How to be able to send form data with the '@' character at the beginning of the data string in PHP cURL

If you post form data using cURL in php, you cannot use the ' @ ' character at the beginning of a data string value (e.g: password=@@mypassword ). ' @ ' is the indicator for file path in POST operation of cURL. You need to disable the '@' prefix to be able to send data string start with '@' character. Here is the description of PHP cURL's CURLOPT_POSTFIELDS option: CURLOPT_POSTFIELDS The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. The filetype can be explicitly specified by following the filename with the type in the format ';type=mimetype'. This parameter can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, value must be an array if files are passed to...

How is the PowerSchool admin login form processed?

Understand how PowerSchool works is very important if you're working as a developer at a school which is using PowerSchool as the Student Information System. PowerSchool is a big web application with a lot of components working together. It will take a huge amount of time to master all of them, so to get started, I will go through the admin login process of PowerSchool. 1. The first time you access the admin login page (http://mydomain.com/admin/pw.html), PowerSchool will give you a random token, pstoken input field of LoginForm: <input type="hidden" name="pstoken" value=" 20233460462xtw69pPuoIBNJ1RyLBnKsfuykVNlJzd "> 2. The admin user input username and password into the form (in the form of < username;password >), and press submit button. 3. Before the form's data is sent to PowerSchool server, the password is hashed using base64 md5 and then hashed again with the token provided in step (1) If the user is a ldap user, the l...