问题
That's all about Phonegap Android and iOS application build on JS.
We have a server with method: - Authorize(login,pass) which return certificate.p12 file (PKCS#12).
Also server has methods, which requires authorization with that certificate. Example on Ruby looks like that:
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
pkcs12 = OpenSSL::PKCS12.new(File.read('<CERTIFICATE_PATH>'),'')
http.cert = pkcs12.certificate
http.key = pkcs12.key
req = Net::HTTP::Get.new(url.path)
result = http.start {|http|
result = http.request(req)
p result.body
}
But how to make that on JS? How make method call's on JS from Phonegap?
The only one solution which I have found: via plugins on Java and iOS, but i'm not sure that they will work. If yes, maybe someone have already made they?
回答1:
I use twitter's finagle and akka to connect to a webservice. You would have to learn scala and how to mix java with scala and install sbt, which would be an option if you have enough time to accommodate a learning curve. Scala also has a very good api for xml parsing.
An application configuration file would specify your security settings. It is worth exploring.
There is a lot of research and coding involved but it is worth it in the long run.
来源:https://stackoverflow.com/questions/8167579/connect-to-web-server-via-phonegap-with-ssl-and-certificate