Changeset 457

Show
Ignore:
Timestamp:
02/19/07 14:53:27 (2 years ago)
Author:
sacha
Message:

added HTTP over SSL support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/branch-https-dev/src/hefeweizen_library_b2b_system.rb

    r451 r457  
    122122        # start exchange points 
    123123        @parameters['exchange-points'].each{ | exchange_point | 
    124           if exchange_point.start then 
     124          if exchange_point.start @ssl_security_information, @cpa_manager then 
    125125            @logger.info "#{me}: Started exchange point." 
    126126          else 
     
    170170        hash = Hash.new 
    171171        path = "#{@certs_dir}/#{reference}" 
    172         (return false, "Reference cannot be found in director '#{@certs_dir}'.") unless FileTest.exists? path 
     172        (return false, "Reference cannot be found in directory '#{@certs_dir}'.") unless FileTest.exists? path 
    173173        hash['certificate_file'] = Dir.glob("#{path}/#{system_name}*_cacert.pem").first 
    174174        hash['private_key_file'] = Dir.glob("#{path}/#{system_name}*_private_key.pem").first 
     
    315315        @completely_configured = true 
    316316 
     317        # update SSL configurations for HTTPs servers 
     318        @ssl_security_information = update_ssl_security_information 
     319 
    317320        return true 
    318321      end 
     
    454457      end 
    455458       
     459      # This information configures the HTTP servers for SSL. 
     460      # Includes setup of: 
     461      # - SSL server certificates 
     462      # - SSL server private key 
     463      # - client ca path 
     464      def update_ssl_security_information 
     465        @logger.debug "#{me}: Parsing ebXML CPA's for this parties HTTP servers." 
     466        config = nil 
     467        ssl_configuration = Hash.new 
     468        @cpa_manager.cpas.each_pair{ |cpa_id, cpa| 
     469 
     470          config = cpa['cpa'].get_this_party_htts_server_security_details @system_name 
     471          if !config.nil? and config.size != 0 then 
     472            ssl_configuration[cpa_id] = config 
     473            @logger.debug "#{me}: CPA with id '#{cpa_id}' has the following SSL server setups. " 
     474            config.each_pair{ | endpoint, sec_details | 
     475              @logger.debug " endpoint '#{endpoint}': " 
     476              sec_details.each{ | security_details_ref | 
     477                @logger.debug "   - #{security_details_ref} " 
     478                dir = @cpa_manager.get_trust_anchor_certificate_directory cpa_id, security_details_ref 
     479                @logger.debug "#{me}: #{(((Dir.entries dir)-['.', '..']).join ", ")}" 
     480              } 
     481            } 
     482          end 
     483 
     484        } 
     485         
     486        # TODO 
     487        # consolidate over CPA'ids 
     488        x_configuration = Hash.new 
     489        ssl_configuration.each_pair{ | cpa_id, configuration | 
     490          configuration.each_pair { | endpoint , sec_details | 
     491            if !x_configuration.has_key? endpoint then 
     492              path = cpa_manager.get_trust_anchor_certificate_directory cpa_id, sec_details 
     493              x_configuration[endpoint] = path 
     494            else 
     495              @logger.debug "#{me}: WARNING: There is already a CPA with this endpoint 'endpoint'" 
     496#              previous_dir =  cpa_manager.x_configuration[endpoint] 
     497#              new_dir = sec_details 
     498            end 
     499          } 
     500        } 
     501         
     502        if @debug then 
     503          require 'pp' 
     504          puts 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
     505          puts 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
     506          pp x_configuration 
     507          puts 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
     508          puts 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
     509        end 
     510        return x_configuration 
     511      end 
    456512 
    457513    end 
  • branches/branch-https-dev/src/hefeweizen_library_business_logic.rb

    r451 r457  
    472472             
    473473            # partner certificates 
    474             ebMS_info['info']['transport-protocol-security-server-cert-file'] = "" 
    475             ebMS_info['info']['transport-protocol-security-server-cas-directory'] = "" 
    476  
    477             # get one of my certificates 
     474            server_cert = @b2b_system.cpa_manager.get_cert ebMS_info['info']['cpa_id'], ebMS_info['info']['transport-protocol-security-server-cert-ref'] 
     475            ebMS_info['info']['transport-protocol-security-server-cert-file'] = server_cert || "" 
     476             
     477            server_cert_trust_anchors_dir = @b2b_system.cpa_manager.get_trust_anchor_certificate_directory ebMS_info['info']['cpa_id'], ebMS_info['info']['transport-protocol-security-server-sec-details-ref'] 
     478            ebMS_info['info']['transport-protocol-security-server-cas-directory'] = server_cert_trust_anchors_dir || "" 
     479 
     480            # get my certificate and private key 
    478481            cert_hash = @b2b_system.get_certficates_path_for_reference ebMS_info['info']['transport-protocol-security-client-cert-ref'] 
    479482            if cert_hash == false then 
     
    482485            else 
    483486              ebMS_info['info']['transport-protocol-security-client-cert-file'] = cert_hash['certificate_file'] 
    484             end 
     487              ebMS_info['info']['transport-protocol-security-client-private-key-file'] = cert_hash['private_key_file'] 
     488            end 
     489 
     490             
    485491             
    486492            # store updated information 
  • branches/branch-https-dev/src/hefeweizen_library_cpa.rb

    r452 r457  
    4242       
    4343      attr_reader :id 
    44        
     44 
    4545      def CPA.create cpa_path, config 
    4646        # and FileTest.owned?(cpa_path) 
     
    5454          return nil 
    5555        end 
     56      end 
     57       
     58      # This method returns a hash with an HTTPS endpoint address as 
     59      # key and an array as value. The array holds the unique cpa  
     60      # security details ref 
     61      def get_this_party_htts_server_security_details party_name 
     62        this_party_info = nil 
     63        if party_name == @xml_cpa.partyInfo.first.xmlattr_partyName then 
     64          this_party_info = @xml_cpa.partyInfo[0] 
     65          other_party_info = @xml_cpa.partyInfo[1] 
     66        else 
     67          this_party_info = @xml_cpa.partyInfo[1] 
     68          other_party_info = @xml_cpa.partyInfo[0] 
     69        end 
     70         
     71        hash = Hash.new 
     72        # Potential problem if there are more than one ClientSeurityDetailsRef per endpoint 
     73        # hash['https://host:port/path'] = "my_super_security_id_1" 
     74        # hash['https://host:port/path'] = "my_super_security_id_2" 
     75        # -> real problem if "my_super_security_id_1" and "my_super_security_id_2" hold different certificates! 
     76        #    because: there will be only ONE https server with this endpoint address and it will not be able do 
     77        #             differentiate between "my_super_security_id_1" and "my_super_security_id_2" 
     78 
     79        transports = this_party_info.transport.class == Array ? this_party_info.transport : [this_party_info.transport] 
     80        transports.each{ | transport | 
     81          if transport.respond_to? "transportReceiver" then 
     82            tr = transport.transportReceiver 
     83            if tr.respond_to? "transportServerSecurity" then 
     84              tss = tr.transportServerSecurity 
     85              if tss.respond_to? "clientSecurityDetailsRef" then 
     86                client_security_details_ref = tss.clientSecurityDetailsRef.xmlattr_securityId.strip 
     87                uri = tr.endpoint.xmlattr_uri.strip 
     88                if !hash.has_key? uri then 
     89                  hash[uri] = Array.new 
     90                end 
     91                if ! hash[uri].include? client_security_details_ref then 
     92                  hash[uri].push client_security_details_ref 
     93                else 
     94                  @logger.debug "#{me}: WARNING URI '#{uri}' has multiple client security details ref in CPA with id '#{id}' for party '#{party_name}'." 
     95                  @logger.debug "#{me}: Regarding multiple client security details ref ... if there are actually different certificates then there is a problem with this setup." 
     96                end 
     97              end 
     98            end 
     99          end 
     100        } 
     101 
     102        return hash 
    56103      end 
    57104 
     
    95142 
    96143        # other party 
     144        # get each XML certificate and create a .pem file 
    97145        if other_party_info.respond_to? "certificate" then 
    98146          certs = other_party_info.certificate.class == Array ? other_party_info.certificate : [other_party_info.certificate] 
    99147          certs.each{ | cert | 
    100148            cert_id = cert.xmlattr_certId 
    101 #            new_dir = "#{cpa_runtime_dir}" 
    102 #            FileUtils.mkdir new_dir 
    103149            add_pem_cert_to_dir cpa_runtime_dir, cert_id 
    104150          } 
    105151        end 
    106152         
    107         # get each XML certificate and create .pem file 
    108153         
    109154      end 
     
    578623 
    579624      # This method reads the Transport information of the CPA. 
    580       # TODO: Security realted aspects (eg HTTPS and its related certificates) 
    581       #       - TransportClientSecurity 
    582       #       - TransportServerSecurity 
     625      # TODO: Probably needs fixing regarding 'incoming' vs 'outgoing' ebXML message. 
    583626      def get_transport_info this_party_transport, other_party_transport 
    584627        return nil if this_party_transport.nil? or other_party_transport.nil? 
     
    593636          info['transport-protocol-security-protocol-version'] = (tss.respond_to? "transportSecurityProtocol") ? tss.transportSecurityProtocol.xmlattr_version : "not set" 
    594637          info['transport-protocol-security-server-cert-ref'] = (tss.respond_to? "serverCertificateRef" and tss.serverCertificateRef.respond_to? "xmlattr_certId") ? tss.serverCertificateRef.xmlattr_certId : "not set" 
     638 
    595639          # I ASSUME THE CPA IS CORRECT! 
     640          # get my SSL client certificate reference id. 
    596641          info['transport-protocol-security-client-cert-ref'] = this_party_transport.transportSender.transportClientSecurity.clientCertificateRef.xmlattr_certId 
    597642          # I ASSUME THE CPA IS CORRECT! 
     643          # get the server certificate trust anchors I will check the server cert against. 
    598644          info['transport-protocol-security-server-sec-details-ref'] = this_party_transport.transportSender.transportClientSecurity.serverSecurityDetailsRef.xmlattr_securityId 
    599645        else 
  • branches/branch-https-dev/src/hefeweizen_library_cpa_manager.rb

    r452 r457  
    3939     
    4040    class CPAManager 
     41 
     42      attr_reader :cpas 
    4143 
    4244      def initialize party_name, party_ids, config, path_to_agreements 
     
    142144      end 
    143145 
     146      # This method returns the directory path of a trust anchor certifiates. 
     147      # eg Certificat A must be signed by either B, C, or D. Certificates B, C, and D are stored in the  
     148      # directory this method returns. The HTTPS client uses this directory to validate a server SSL certificate. 
     149      def get_trust_anchor_certificate_directory cpa_id, security_details_id 
     150        dir = get_cpa_runtime_dir cpa_id 
     151        retunr nil if dir.nil? 
     152        "#{dir}/#{security_details_id}" 
     153      end 
     154 
     155      # This method returns the filename of a requested certificate. The request is made by the CPA id and the certificate id. 
     156      def get_cert cpa_id, cert_id 
     157        dir = get_cpa_runtime_dir cpa_id 
     158        return nil if dir.nil? 
     159        "#{dir}/#{cert_id}.pem" 
     160      end 
     161       
    144162      def get_cpa_runtime_dir cpa_id 
    145163        if @cpa_id_md5sum.has_key? cpa_id then 
  • branches/branch-https-dev/src/hefeweizen_library_exchange_point.rb

    r451 r457  
    3838    # This class reads the exchange point information and sets up an exchange point. 
    3939    class ExchangePoint 
    40  
     40       
    4141      attr_reader :exchange_points_config 
    4242 
     
    8787 
    8888      # This method will start a new exchange tasker 
    89       def start 
     89      def start ssl_security_information, cpa_manager 
    9090        @logger.debug "Starting exchange point." 
    9191        # creating the directories 
     
    9595          # 
    9696          if exchange_point_config[:protocol] == 'http' || exchange_point_config[:protocol] == 'https' then 
    97             server_cert_dir = "" 
     97            ssl_sever_configuration = "" 
    9898            if exchange_point_config[:protocol] == 'https' then 
    99               server_cert_dir = " --server-cert-dir #{exchange_point_config[:server_cert_dir]}" 
     99              ssl_sever_configuration = " --server-cert-dir #{exchange_point_config[:server_cert_dir]}" 
     100              server_endpoint = "#{exchange_point_config[:protocol]}://#{exchange_point_config[:host]}:#{exchange_point_config[:port]}#{exchange_point_config[:path]}" 
     101              @logger.debug "#{me}: Checking if server endpoint '#{server_endpoint}' requires a client SSL certificate ca path." 
     102              ssl_security_information.keys.each{ | key | 
     103                puts key 
     104              } 
     105              if ssl_security_information.has_key? server_endpoint then 
     106                @logger.debug "#{me}: This HTTPS Server uses a client ca path: '#{ssl_security_information[server_endpoint]}'" 
     107                ssl_sever_configuration += " --client-ca-path #{ssl_security_information[server_endpoint]}" 
     108              else 
     109                @logger.debug "#{me}: no matching endpoint found." 
     110                require 'pp' 
     111                pp ssl_security_information 
     112              end 
    100113            end 
    101114 
    102             tasker_argument = "--b2b-system-name #{@b2b_system_name} --pipe-to-ania #{@config['PIPE_TO_ANIA']} --port #{exchange_point_config[:port]} --path #{exchange_point_config[:path]} #{server_cert_dir} --config #{@config['CONFIG_DIR']}/hefeweizen.conf" 
     115            tasker_argument = "--b2b-system-name #{@b2b_system_name} --pipe-to-ania #{@config['PIPE_TO_ANIA']} --port #{exchange_point_config[:port]} --path #{exchange_point_config[:path]} #{ssl_sever_configuration} --config #{@config['CONFIG_DIR']}/hefeweizen.conf" 
    103116             
    104117            command_hash = { 
  • branches/branch-https-dev/src/taskers/hefeweizen_tasker_application_http_server.rb

    r451 r457  
    3838require 'fileutils' 
    3939require 'logger' 
     40require 'pp' 
    4041 
    4142$exit = false 
     
    108109        file_full.close 
    109110         
    110         require 'pp' 
    111         puts '-------------------------------' 
    112         puts req.meta_vars 
    113         puts '-------------------------------' 
    114         puts req.meta_vars['SSL_CLIENT_CERT'] 
    115         puts '-------------------------------' 
    116         puts req.client_cert 
     111        if @is_https then 
     112          puts '-------------------------------' 
     113          puts 'General Request information ' 
     114          puts req.meta_vars.class 
     115          puts req.meta_vars 
     116          puts '-------------------------------' 
     117          puts 'The Client Certificate' 
     118          puts req.meta_vars['SSL_CLIENT_CERT'] 
     119          puts '-------------------------------' 
     120        end 
    117121 
    118122        # 2. 
     
    267271                              [ '--path', '-x', GetoptLong::REQUIRED_ARGUMENT ], 
    268272                              [ '--server-cert-dir', '-s', GetoptLong::OPTIONAL_ARGUMENT ], 
     273                              [ '--client-ca-path', '-e', GetoptLong::OPTIONAL_ARGUMENT ], 
    269274                              [ '--config', '-c', GetoptLong::REQUIRED_ARGUMENT ] 
    270275                              ) 
     
    276281        @path = nil 
    277282        @server_cert_dir = nil 
     283        @client_ca_path = nil 
    278284        @is_https = false 
    279285        opts.each do |opt, arg| 
     
    292298            @server_cert_dir = arg 
    293299            @is_https = true 
     300          when '--client-ca-path' 
     301            @client_ca_path = arg 
    294302          end 
    295303        end 
     
    324332        require "#{@config['LIB_DIR']}/hefeweizen_library_utils" 
    325333 
    326  
     334         
    327335        if @is_https then 
    328           if !(FileTest.exists? @server_cert_dir and FileTest.directory? @server_cert_dir) then 
     336          if !(!@server_cert_dir.nil? and FileTest.exists? @server_cert_dir and FileTest.directory? @server_cert_dir) then 
    329337            @logger.error "#{me}: Unable to locate server certificate directory '#{@server_cert_dir}'." 
    330338            # exit -1 ? 
     
    332340            @private_key_file = Dir.glob("#{@server_cert_dir}/*private_key.pem").first 
    333341            @cert_file = Dir.glob("#{@server_cert_dir}/*_cacert.pem").first 
     342 
    334343            # @private_key_password_file = Dir.glob("#{@server_cert_dir}/*private_key.password").first 
    335344            if !(FileTest.exists? @cert_file and FileTest.readable? @cert_file) then 
    336               @logger.error "#{me}: The HTTP servers SSL certificate does not exist or is not readable. Please fix." 
     345              @logger.error "#{me}: The HTTP servers SSL certificate does not exist or is not readable. Please fix this first." 
    337346              exit -1 
    338347            end 
    339             if !(FileTest.exists? @private_key_file and FileTest.readable? @private_key_file) then 
    340               @logger.error "#{me}: The HTTP Server's private key file does not exist or is not readable. Please fix." 
     348            if !(!@private_key_file.nil? and FileTest.exists? @private_key_file and FileTest.readable? @private_key_file) then 
     349              @logger.error "#{me}: The HTTP Server's private key file does not exist or is not readable. Please fix this first." 
    341350              exit -1 
    342351            end 
    343           end 
    344            
    345         end 
    346  
    347       end 
    348  
    349       def me 
    350         "HefeWeizen HTTP(S) Server" 
    351       end 
     352             
     353            if !(!@client_ca_path.nil? and FileTest.exists? @client_ca_path and FileTest.directory? @client_ca_path) then 
     354              @logger.error "#{me}: The value of client-ca-path of '#{@client_ca_path}' does not exist or ist not a directory. Please fix this first." 
     355              exit -1 
     356            end 
     357          end 
     358 
     359           
     360        end 
     361 
     362      end 
     363 
    352364       
    353365      def run 
     
    357369      private 
    358370 
     371      def me 
     372        "HefeWeizen HTTP(S) Server" 
     373      end 
     374 
    359375      def http_server_serve 
    360376        if @is_https then 
    361377           
    362           pkey = cert = cert_name = client_ca = nil 
     378          client_ca_path = @client_ca_path 
     379 
     380          server_private_key = server_certificate = nil 
     381 
     382          puts "Private key file: #{@private_key_file}" 
     383          puts "Sever cert file:  #{@cert_file}" 
     384          puts "Client CA path:   #{@client_ca_path}" 
     385           
    363386          begin 
    364             pkey = OpenSSL::PKey::RSA.new(File.open(@private_key_file).read) 
    365             cert = OpenSSL::X509::Certificate.new(File.open(@cert_file).read) 
    366             client_ca = OpenSSL::X509::Certificate.new(File.open("/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem").read) 
     387            server_certificate = OpenSSL::X509::Certificate.new(File.open(@cert_file).read) 
     388            server_private_key = OpenSSL::PKey::RSA.new(File.open(@private_key_file).read) 
     389            # client_ca = OpenSSL::X509::Certificate.new(File.open("/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem").read) 
     390            # SSLCACertificateFile is a Filename 
     391            # ssl_ca_certificate_file = "/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem", 
    367392          rescue 
    368393            @logger.error "#{me}: Unable to create HTTPs server." 
    369394            exit -1 
    370             #            $stderr.puts "Switching to use self-signed certificate" 
    371             #            cert_name = [ ["C","JP"], ["O","WEBrick.Org"], ["CN", "WWW"] ] 
    372395          end 
    373396           
     
    392415=end     
    393416           
    394  
    395           s=WEBrick::HTTPServer.new({ 
    396                                       :Port             => @port, 
    397                                       :Logger           => @logger, 
    398                                       :SSLEnable        => true, 
    399 #                                    :SSLVerifyClient  => OpenSSL::SSL::VERIFY_NONE, 
    400                                       #                                    :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER, 
    401                                       #OpenSSL::SSL::VERIFY_PEER |  
    402                                       :SSLVerifyClient => OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT, 
    403                                       :SSLCACertificateFile => "/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem", 
    404                                       :SSLClientCA => client_ca, 
    405                                       #                                    :SSLClientCA => "/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem", 
    406                                       :SSLCertificate   => cert, 
    407                                     :SSLPrivateKey    => pkey, 
    408                                       #                                    :SSLPrivateKeyPassPhrase    => "passphrase", 
    409                                       :SSLCertName      => cert_name, 
    410                                       :SSLCertComment   => "HefeWeizen SSL notice" 
    411                                     } ) 
     417           
     418          server = WEBrick::HTTPServer.new({ 
     419                                             :Port             => @port, 
     420                                             :Logger           => @logger, 
     421                                             :SSLEnable        => true, 
     422                                              
     423                                             # :SSLCertificate is a OpenSSL::X509::Certificate instance 
     424                                             :SSLCertificate   => server_certificate, 
     425                                             # SSLPrivateKey is a OpenSSL::PKey::RSA 
     426                                             :SSLPrivateKey    => server_private_key, 
     427                                             # :SSLPrivateKeyPassPhrase    => "passphrase", 
     428                                             # :SSLCertName      => cert_name, 
     429                                             # :SSLCertComment   => "HefeWeizen SSL notice", 
     430                                              
     431                                             # default setting: :SSLVerifyClient  => OpenSSL::SSL::VERIFY_NONE, 
     432                                             # another setting: :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER, 
     433                                             :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT, 
     434                                              
     435                                             :SSLCACertificatePath => @client_ca_path 
     436                                              
     437                                             # SSLCACertificateFile is a Filename 
     438                                             # :SSLCACertificateFile => ssl_ca_certificate_file 
     439                                              
     440                                             # :SSLClientCA is a OpenSSL::X509::Certificate instance 
     441                                             # :SSLClientCA => client_ca 
     442 
     443                                             # -> this server is used for multiple client certificates. 
     444                                              
     445                                           } ) 
    412446        else 
    413447          # :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER | ::OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT 
    414448          # :SSLCACertificateFile => File.dirname(__FILE__) + "/xxx-my-ca.crt", 
    415449          # :SSLVerifyDepth  => 2, 
    416           s = WEBrick::HTTPServer.new( {:Logger => @logger, :Port => @port} ) 
    417         end 
    418  
    419         s.mount @path, InitializedEBMSServlet, @b2b_system_name, @config, @pipe_to_ania 
    420         trap("INT"){ s.shutdown } 
    421         s.start 
     450          server = WEBrick::HTTPServer.new( {:Logger => @logger, :Port => @port} ) 
     451        end 
     452 
     453        server.mount @path, InitializedEBMSServlet, @b2b_system_name, @config, @pipe_to_ania 
     454        trap("INT"){ server.shutdown } 
     455        server.start 
    422456        return 0 
    423457      end 
  • branches/branch-https-dev/src/taskers/hefeweizen_tasker_application_send_ebXML_message.rb

    r451 r457  
    161161            ca_directory = @ebXML_message_parameters['info']['transport-protocol-security-server-cas-directory'] || "" 
    162162            client_certificate = @ebXML_message_parameters['info']['transport-protocol-security-client-cert-file'] || "" 
    163              
    164             if ca_certificate.empty? or ca_directory.empty? or client_certificate.empty? then 
     163            private_key = @ebXML_message_parameters['info']['transport-protocol-security-client-private-key-file'] || "" 
     164 
     165            if ca_certificate.empty? or ca_directory.empty? or client_certificate.empty? or private_key.empty? then 
    165166              msg = "Required SSL configuration information is missing. Check the values of the ca_certificate: '#{ca_certificate}', " + 
    166                 "ca_directory = '#{ca_directory}', or client certificate: '#{client_certificate}'." 
     167                "ca_directory = '#{ca_directory}', client certificate: '#{client_certificate}', or priate key: '#{priate_key}'." 
    167168              # @logger.error "#{me}: #{msg}" 
    168169              # ssl_configurations = "--no-check-certificate" 
    169170              puts "Errro #{msg}"  
    170171            else 
    171               ssl_configurations = "--ca-certificate=#{ca_certificate} --ca_directory=#{ca_directory} --certificate=#{client_certificate}" 
     172              ssl_configurations = "--ca-certificate=#{ca_certificate} --ca-directory=#{ca_directory} --certificate=#{client_certificate} --private-key=#{private_key}" 
    172173            end 
    173174             
  • branches/branch-https-dev/test/tools/hefeweizen_tool_tester.rb

    r447 r457  
    116116    # ----------------------------------- 
    117117 
    118  
    119 # =begin 
     118=begin 
     119 
    120120    # a directive that misses the service and action 
    121121    n.times{ 
     
    290290    results << search_log_files_for_errors 
    291291 
    292 #=end 
    293  
     292=end 
     293 
     294=begin 
     295    # HTTP over SSL. 
     296    n.times{  
     297      results << test_dynamic_sending_messages( "Coronation", "Gnaraloo", "ebXML CPA ebXML MS test CPA HTTPS", "send_a_message_1", "ebMSebCPPATests", iterations, "reliable" ) 
     298    } 
     299 
     300    n.times{  
     301      results << test_dynamic_sending_messages( "Coronation", "Gnaraloo", "ebXML CPA ebXML MS test CPA HTTPS", "send_a_message_2", "ebMSebCPPATests", iterations, "reliable" ) 
     302    } 
     303=end 
     304    n.times{ 
     305      results << test_dynamic_sending_messages_and_ssl_problem( "Coronation", "Gnaraloo", "ebXML CPA ebXML MS test CPA HTTPS", "send_a_message_3_bad", "ebMSebCPPATests", iterations) 
     306    } 
     307 
     308 
     309 
     310# =end 
    294311=begin 
    295312 
     
    919936    @logger.debug "From Party Name: '#{from_party_name}', To Party Name: '#{to_party_name}', CPA ID: '#{cpa_id}', Action: '#{action}', Number of messages: '#{iterations}'." 
    920937    reliable = reliable_string == 'reliable' ? true : false  
     938 
    921939    dir = "#{@result_dir}/test_dynamic_sending_messages_and_things_go_bad_#{action}_#{Time.now.to_s}" 
    922940    FileUtils.mkdir(dir) 
     
    962980 
    963981    elsif action =~ /send_a_message_(.*)/ then 
    964        
    965982      if reliable == false then 
    966983        # non reliable messaging 
     
    10461063    gnaraloo_message_states_expectations = nil 
    10471064    expectations = nil 
    1048      
     1065 
    10491066    if action == 'Ping' then 
    10501067      coronation_message_states_expectations = { 
     
    11461163     
    11471164    return compare_validation("test_dynamic_sending_messages: #{action}", dir, result, expectations ) 
     1165  end 
     1166   
     1167  def test_dynamic_sending_messages_and_ssl_problem from_party_name, to_party_name, cpa_id, action, service, iterations 
     1168    @logger.debug "Starting test_dynamic_sending_messages_and_ssl_problem at #{Time.now.to_s}" 
     1169    @logger.debug "From Party Name: '#{from_party_name}', To Party Name: '#{to_party_name}', CPA ID: '#{cpa_id}', Action: '#{action}', Number of messages: '#{iterations}'." 
     1170 
     1171    dir = "#{@result_dir}/test_dynamic_sending_messages_and_ssl_problem_#{action}_#{Time.now.to_s}" 
     1172    FileUtils.mkdir(dir) 
     1173     
     1174    system "sh run-clear-system.sh" 
     1175 
     1176    coronation_message_states_expectations = nil 
     1177    gnaraloo_message_states_expectations = nil 
     1178    expectations = nil 
     1179 
     1180    # non reliable messaging 
     1181    coronation_message_states_expectations = { 
     1182      'failed_to_send' => iterations 
     1183    } 
     1184    gnaraloo_message_states_expectations = {} 
     1185 
     1186    expectations = { 
     1187      'total_open_trans' => 0,  
     1188      'total_closed_trans' => iterations, 
     1189      'total_closed_trans_succeeded' => 0, 
     1190      'total_closed_trans_failed' => iterations, 
     1191      'total_temp_files' => 0, 
     1192      'coronation_number_ebXML_messages' => iterations, 
     1193      'coronation_number_conversations' => iterations, 
     1194      'coronation_incoming_directives' => 0, 
     1195      'coronation_incoming_payloads' => 0, 
     1196      'coronation_errors' => iterations, 
     1197      'coronation_message_states' => coronation_message_states_expectations, 
     1198      'gnaraloo_number_ebXML_messages' => 0, 
     1199      'gnaraloo_number_conversations' => 0, 
     1200      'gnaraloo_incoming_directives' => 0, 
     1201      'gnaraloo_incoming_payloads' => 0, 
     1202      # WILL BECOME A CONFIGURATION OPTION! 
     1203      'gnaraloo_errors' => 0, 
     1204      'gnaraloo_message_states' => gnaraloo_message_states_expectations 
     1205    } 
     1206     
     1207    create_and_copy_directive from_party_name, to_party_name, cpa_id, action, service, iterations 
     1208     
     1209    sleep iterations * BIG_SLEEP * 2 
     1210       
     1211    result = get_statistics_information 
     1212    file = File.new "#{dir}/statistics", "w" 
     1213    file << "Statistics information after exchange of messages: \n\n" 
     1214    result.each_pair{ | key, value | 
     1215      if value.class == Hash then 
     1216        file << "#{key}:\n" 
     1217        value.each_pair{ | inner_key, inner_value | 
     1218          file << "    #{inner_key}: #{inner_value}\n" 
     1219        } 
     1220      else 
     1221        file << "#{key} : #{value}\n" 
     1222      end 
     1223    } 
     1224     
     1225    file.close 
     1226    #require 'pp'; pp result 
     1227     
     1228    return compare_validation("test_dynamic_sending_messages_and_ssl_problem: #{action}", dir, result, expectations ) 
    11481229  end 
    11491230 
  • branches/branch-https-dev/test/unit-tests/tc_hefeweizen_library_cpa_test.rb

    r301 r457  
    3535require 'fileutils' 
    3636require '../../src/hefeweizen_library_cpa' 
     37require '../../src/hefeweizen_library_cpa_manager' 
    3738 
    3839class HefeWeizenLibraryCPATest < Test::Unit::TestCase 
     
    5253                                         { :type => "urn:li.gnaraloo.b2b", :id => "gnaraloo_test_system"} ] 
    5354    @logger = Logger.new(STDOUT) 
    54     @mock_config = { 'TEMP_FILE_DIR' => @temp_dir, 'LOGGER' => @logger } 
     55    @temp_dir = "./tmp" 
     56    @mock_config = { 'TEMP_FILE_DIR' => @temp_dir, 'LIB_DIR' => "../../src/", 'CPA_DIR' => @temp_dir, 'LOGGER' => @logger } 
    5557  end 
    5658 
    5759  def teardown 
    5860    FileUtils.rm_rf "tmp" if FileTest.exists? "tmp" and FileTest.directory? "tmp" 
     61     
    5962  end 
    6063 
  • branches/branch-https-dev/test/unit-tests/tc_hefeweizen_library_exchange_point_test.rb

    r301 r457  
    5151  end 
    5252 
    53   class B2BSystemMock 
    54   end 
    55  
    5653  def setup 
    5754    @config = Hash.new 
     
    5956    @config['LIB_DIR'] = "../../src/" 
    6057    @config_file = "../test-systems/Coronation/infrastructure/exchange-points/http_server.conf" 
     58    @certs_dir = "./tmp" 
    6159  end 
    6260 
    6361  def teardown 
    64  
     62    FileUtils.rm_rf @certs_dir if FileTest.exists? @certs_dir 
    6563  end 
    6664 
     
    6866    not_existing = "not_existing" 
    6967    begin  
    70       HefeWeizen::HefeWeizenLibrary::ExchangePoint.new B2BSystemMock.new, not_existing, self, @config 
     68      HefeWeizen::HefeWeizenLibrary::ExchangePoint.new "Coronation", not_existing, @certs_dir, self, @config 
    7169      fail 
    7270    rescue Exception => e 
     
    7674 
    7775  def test_open_exchange_point_configuration_file 
    78     exchange_point = HefeWeizen::HefeWeizenLibrary::ExchangePoint.new B2BSystemMock.new, @config_file, self, @config 
     76    exchange_point = HefeWeizen::HefeWeizenLibrary::ExchangePoint.new "Coronation", @config_file, @certs_dir, self, @config 
    7977    assert_kind_of HefeWeizen::HefeWeizenLibrary::ExchangePoint, exchange_point, "Must be an ExchangePoint" 
    8078 
    8179    assert_kind_of Array, exchange_point.exchange_points_config, "Must be an Array" 
    82     assert_equal 1, exchange_point.exchange_points_config.size, "Must have 1 exchange point" 
     80    assert_equal 3, exchange_point.exchange_points_config.size, "Must have 1 exchange point" 
    8381    assert_equal "http", exchange_point.exchange_points_config.first[:protocol], "Must be a HTTP exchange point" 
    84     assert_equal "localhost", exchange_point.exchange_points_config.first[:host], "Must be a HTTP exchange point" 
     82    assert_equal "coronation-ebXML-b2b-gateway", exchange_point.exchange_points_config.first[:host], "Must be a HTTP exchange point" 
    8583    assert_equal 7777, exchange_point.exchange_points_config.first[:port], "Must be a HTTP exchange point" 
    8684    assert_equal "/coronation", exchange_point.exchange_points_config.first[:path], "Must be a HTTP exchange point"