Hello,I'm trying to use the Cloud API to upload some documents. If I post the document all work well, but I cannot use the url upload since I obtain an cURL error related to SSL.
To put an example, if I call the following URL all goes fine:
https://api.pdftron.com/v1/document?xodEncryptPassword=123456789&fileName=ENC.pdfWhen I try to upload content using the URL method, the call returns a SSL cURL Error:
RESPONSE: "null"
cURL Error: "SSL read: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number, errno 0"Thank you :)
Kevin Kuo
Software
Developer
PDFTron
Systems, Inc.
www.pdftron.com
Tel:
1-604-730-8989
Fax: 1-604-676-2477
CONFIDENTIALITY NOTICE: This message (and any attachment to it) is intended only for the use of the individual or entity to which it is addressed in the header, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Any reproduction, distribution, modification or use of the contents of this message (and any attachment to it) by any individual or entity other than the intended recipient is prohibited. If you have received this communication in error, please notify us immediately and delete the original.
P Please think before you print!
Hello again Kevin,I have tried to do the upload using the command line curl, and it works:$ curl -k -v --ssl-reqd --user .... --request POST "https://api.pdftron.com/v1/document?fileUrl=https%3A%2F%2Fdl.dropboxusercontent.com%2Fu%...&fileName=ENC.pdf"* About to connect() to api.pdftron.com port 443 (#0)* Trying 50.112.120.165...* connected* Connected to api.pdftron.com (50.112.120.165) port 443 (#0)* SSLv3, TLS handshake, Client hello (1):* SSLv3, TLS handshake, Server hello (2):* SSLv3, TLS handshake, CERT (11):* SSLv3, TLS handshake, Server key exchange (12):* SSLv3, TLS handshake, Server finished (14):* SSLv3, TLS handshake, Client key exchange (16):* SSLv3, TLS change cipher, Client hello (1):* SSLv3, TLS handshake, Finished (20):* SSLv3, TLS change cipher, Client hello (1):* SSLv3, TLS handshake, Finished (20):* SSL connection using EDH-RSA-DES-CBC3-SHA...< HTTP/1.1 201 Created...< Content-Length: 206< Date: Tue, 04 Jun 2013 17:48:44 GMT<* Connection #0 to host api.pdftron.com left intact<?xml version="1.0" encoding="UTF-8" standalone="yes"?><document><documentId>0354cb9187ed44bab31340b76e4c10b9</documentId><name>ENC.pdf</name><originalState>Empty</originalState><demo>true</demo></document>* Closing connection #0* SSLv3, TLS alert, Client hello (1):I have made some research and realized that the error arises because of an empty POST message. I arrange the script and now it seems to work properlycurl_setopt($ch, CURLOPT_URL, $url = $apiUploadEndpoint . 'fileUrl=' . urlencode($file_url) . '&fileName=' . $file_name);curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );curl_setopt($ch, CURLOPT_USERPWD, $API_KEY . ':' . $API_SECRETKEY);curl_setopt($ch, CURLOPT_HTTPHEADER,array ("Accept: application/json"));curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch, CURLOPT_POSTFIELDS, array() );And now I get the file uploaded and a expected response:{"documentId":"20bffbad283e465a96518cc171c776b0","name":"ENC.pdf","originalState":"Empty","demo":"true"}
PS: Why the parameter "demo" is set to true?
On Monday, June 3, 2013 11:16:10 PM UTC+2, Roi Rodríguez Sánchez wrote:Hi Kevin,I'm currently using a PHP script. To upload a file via POST:$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'https://api.pdftron.com/v1/document?fileName=' . $file_name);curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );curl_setopt($ch, CURLOPT_USERPWD, $API_KEY . ':' . $API_SECRETKEY);curl_setopt($ch, CURLOPT_HTTPHEADER,array ("Accept: application/json"));curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch, CURLOPT_POSTFIELDS, array('file'=>"@$file_to_upload"));$r = curl_exec($ch);To upload a file via URL:$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url = 'https://api.pdftron.com/v1/document?fileUrl=' . urlencode($file_url) . '&fileName=' . $file_name);curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );curl_setopt($ch, CURLOPT_USERPWD, $API_KEY . ':' . $API_SECRETKEY);curl_setopt($ch, CURLOPT_HTTPHEADER,array ("Accept: application/json"));curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_POST, true);$r = curl_exec($ch);The first piece of code works as expected, and we have used it to upload content to the Cloud API. We use the URL method because a very large file (>300MB), but besides using mostly the same code when executed curl gives an error:
SSL read: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number, errno 0
Any idea, or orientation, would be much apreciated :)My command line curl gives this version:$ curl -Vcurl 7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftpFeatures: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libzMy phpinfo shows a coherent info with de command line curl:curlcURL support => enabledcURL Information => 7.24.0Age => 3FeaturesAsynchDNS => YesDebug => NoGSS-Negotiate => YesIDN => NoIPv6 => YesLargefile => YesNTLM => YesSPNEGO => NoSSL => YesSSPI => Nokrb4 => Nolibz => YesCharConv => NoProtocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, smtp, smtps, telnet, tftpHost => x86_64-apple-darwin12.0SSL Version => OpenSSL/0.9.8rZLib Version => 1.2.5
--
You received this message because you are subscribed to the Google Groups "PDFTron WebViewer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfnet-webview...@googlegroups.com.
To post to this group, send email to pdfnet-w...@googlegroups.com.
Visit this group at http://groups.google.com/group/pdfnet-webviewer?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.