Authentication over web service via Curl
I'm currently working on a service to send data from one website 开发者_Python百科to another in order to update a record on the receiving site. I'm using Curl for the web service communication.
I'm wondering what the best solution is to implementing some kind of authentication. The authentication isn't based on a user logged in the site. How will the authentication work? Is it a matter of md5 encrypting a known string to the receiving end and comparing this?
Any suggestions, help and examples would be much appreciated.
Thanks
You could just use basic authentication by passing curl
curl --basic -u "plain_username:plain_password" https://some.foo...
You could use an https address to ensure the username and password are encrypted during transport. If you want to do something more complicated, you probably want to either sign or encrypt the message itself using a private key and pre-share the public key with whoever is running the server. (they would then have to either verify your signature or decrypt the message, depending on what you chose)
I don't think you can do that with curl alone and would need to do that in a small script before calling curl. However for something simple, Basic Authentication over HTTPS should be fairly secure.
精彩评论