Changes between Version 80 and Version 81 of XmlRpcPlugin


Ignore:
Timestamp:
Aug 25, 2010 8:15:44 PM (4 years ago)
Author:
sobersabre
Comment:

added ssl related changes.

Legend:

Unmodified
Added
Removed
Modified
  • XmlRpcPlugin

    v80 v81  
    222222=== Using from Ruby === 
    223223You can either use the XMLRPC functionality included in the [http://ruby-doc.org/stdlib/libdoc/xmlrpc/rdoc/index.html Ruby Standard Library] or [/attachment/wiki/XmlRpcPlugin/trac4r.tar.gz download the trac4r library] which does all the trivial stuff for you. 
     224 
     225please refer to the '''SSL Support''' section if you need one. 
    224226 
    225227==== trac4r Example ==== 
     
    260262  f.write trac.wiki.get_attachment "NameOfThePage", "my_cool_document.pdf" 
    261263end 
     264 
     265# upload an attachment to the page above 
     266page = "NameOfThePage" 
     267fn = "my_nice_doc.pdf" 
     268fh = File.new(fn, "rb") 
     269sdata = fh.read 
     270data = XMLRPC::Base64.new(sdata) 
     271result = trac.wiki.put_attachment(page, name, "uploaded via ruby script", data) 
     272# the correct result should be the name of the file: 
     273puts "ERROR: uploading #{name} didn't work properly!" if result != name 
    262274}}} 
    263275 
     
    291303}}} 
    292304 
    293 === API Usage ===  
     305=== SSL Support + X509 === 
     306The standard ruby xmlrpc client for some reason does not support the above setup. 
     307In order to be able to use the XMLRPC over SSL with both 
     308 * Client Certificate authentication 
     309 * Basic Authentication 
     310in order to proceed, you should have: 
     311 * ca certificate in .pem format 
     312 * personal certificate + RSA key in .p12 format (and its password, of course) 
     313 * patched version of xmlrpc/client.rb 
     314 * patched version of trac4r 
     315 * username/password (for basic authentication) 
     316 
     317Assuming you have the above, and your ca and user certificates are respectively: 
     318{{{ 
     319~/.openssl/cacert.pem 
     320~/.openssl/certkey.p12 
     321}}} 
     322==== Instructions ==== 
     323 # apply the patches: 
     324   # to the xmlrpc library 
     325   # to the trac4r gem to pick up the patch features 
     326 # create a .yml file called {{{~/.trac/creds.yml}}} of the following structure: 
     327{{{ 
     328---  
     329tracurl: https://yourserver.yourdomain/yourproject 
     330tracuser: yourwebuser 
     331tracpass: yourwebpassword 
     332certkey: /home/youruser/.ssl/certkey.p12 
     333cacert: /home/youruser/.ssl/cacert.pem 
     334keypass: yourkeypassword 
     335}}} 
     336 # use the data in the code 
     337{{{ 
     338#!ruby 
     339require 'yaml' 
     340require 'openssl' 
     341require 'xmlrpc/client' 
     342require 'trac4r' 
     343 
     344## read the data from yaml: 
     345$ymlname= "#{ENV['HOME']}/.trac/creds.yml" 
     346if !File.exists?($ymlname)  
     347    raise "Cannot open credentials file!" 
     348end 
     349begin 
     350    $vars = YAML::load_file($ymlname) 
     351rescue Exception => e 
     352    raise "Cannot load credentials file #{$ymlname}: #{e.message}\nTrace: #{e.stacktrace}" 
     353end 
     354 
     355## extract the certificate, and the key from the fles. 
     356pkcs = OpenSSL::PKCS12.new(File.open($vars['certkey']),$vars['keypass']) 
     357cert = pkcs.cert 
     358key = pkcs.key 
     359## connect to the server 
     360trac = Trac.new($vars['tracurl'], $vars['tracuser'], $vars['tracpass'], $vars['cacert'], cert, key) 
     361## from now you can refer to the connection as open (or query it) 
     362## use the API as explained above. 
     363}}} 
     364 
     365 
     366 
     367 
     368 
     369 
     370 
     371=== API Usage === 
    294372          
    295373See the [source:xmlrpcplugin/0.10/tracrpc/api.py source] for details.  
     
    307385== Author/Contributors ==  
    308386 
    309 '''Authors and contributors:''' [wiki:athomas], [wiki:mgood], [wiki:osimons], [wiki:olemis Olemis Lang] [[BR]]  
     387'''Authors and contributors:''' [wiki:athomas], [wiki:mgood], [wiki:osimons], [wiki:olemis Olemis Lang] [wiki:sobersabre] [[BR]] 
    310388'''Maintainer:''' [wiki:osimons] [[BR]]