`
xiaoheliushuiya
  • 浏览: 416179 次
文章分类
社区版块
存档分类
最新评论

关于ssl证书的格式转换以及各方式的使用 收集以及案例,工具soap-ui

 
阅读更多

关于ssl证书的格式转换以及各方式的使用 收集以及案例



http://stackoverflow.com/questions/12162975/openssl-not-enough-data

openssl x509 -inform der -in"c:\mydir\test.cer" -out"C:\mydir\certificate.pem"
openssl pkcs12 -in"c:\mydir\test.pfx" -nocerts -out"c:\mydir\test_pk.pem"

http://www.linuxspy.info/tag/convert-ssl-certificate-pfx-to-pem/

http://mccltd.net/blog/?p=1299


http://ruby-doc.org/stdlib-2.0/libdoc/openssl/rdoc/OpenSSL/X509/Certificate.html

truststore

http://mislav.uniqpath.com/2013/07/ruby-openssl/

http://blog.kabisa.nl/2009/12/04/ruby-and-ssl-certificate-validation/

http://stackoverflow.com/questions/2507902/how-to-validate-ssl-certificate-chain-in-ruby-with-net-http

http://stackoverflow.com/questions/9199660/why-is-ruby-unable-to-verify-an-ssl-certificate

http://www.ruby-doc.org/gems/docs/m/mack-encryption-0.8.3/EzCrypto/TrustStore.html

File.open("client_certificate.pem",'rb' ) { |f| cert = f.read }
File.open("client_key.pem",'rb' ) { |f| key = f.read }
http_session.cert =OpenSSL::X509::Certificate.new(cert)
http_session.key =OpenSSL::PKey::RSA.new(key,nil)

cert — key
https://github.com/augustl/net-http-cheat-sheet/blob/master/ssl_and_https.rb

http://www.spacevatican.org/2009/7/11/ruby-openssl-and-client-side-certificates/

http://stackoverflow.com/questions/10262676/add-ssl-to-a-connection

http://stackoverflow.com/questions/12836847/how-to-establish-a-ssl-enabled-tcp-ip-connection-in-ruby


http://stackoverflow.com/questions/7263960/convert-sslsocket-python-code-to-ruby


tiaoshi
https://www.google.com.hk/search?newwindow=1&safe=strict&espv=2&es_sm=91&q=SSL_connect+returned%3D1+errno%3D0+state%3DSSLv3+read+server+certificate+B%3A+certificate+verify+failed&oq=SSL_connect+returned%3D1+errno%3D0+state%3DSSLv3+read+server+certificate+B%3A+certificate+verify+failed&gs_l=serp.12...116986.116986.0.118655.1.1.0.0.0.0.97.97.1.1.0....0...1c.2.40.serp..1.0.0.Y62fuKpze98


http://stackoverflow.com/questions/4528101/ssl-connect-returned-1-errno-0-state-sslv3-read-server-certificate-b-certificat

http://blog.marc-seeger.de/2012/06/22/ruby-openssl-and-econnreset/



http://mislav.uniqpath.com/2013/07/ruby-openssl/


CONF_GW['cert_path']

---
development:
  cert_path: config/cert/dev/client.pem



require 'timeout'

module EciticHttp
  class Error < Exception
    attr_accessor :number
  end

  class SystemTimeoutError < Timeout::Error
  end

  class TCPTimeoutError < Timeout::Error
  end

  class ProductTypeResult
  end


  class SoapHttp
    include EciticHttp::XMLUtil

    # tcp_timeout做为open_timeout的时间,如果这个时间内没有能打开,则直接timeout退出 
    # timeout为原系统timeout,任务到时间后会退出
    # 这里默认改为10分钟 ,防止保留太多的TCP连接
    attr_accessor :response_data,:response_code,:post_data,:url, :cookie, :response_type,:timeout,:tcp_timeout

    def initialize(p={})
      @cookie         = p[:cookie]
      @url            = p[:url] || Setting.ecitic.order_query
      @response_type  = p[:response_type] || 'request'
      @timeout        = p[:timeout] || 600
      @tcp_timeout    = p[:tcp_timeout] || 120

    end
    
    def soap_login(method, post_data)
      headers = {
        'Referer'       => 'http://www.appfusion.net',
        'Content-Type'  => 'text/xml; charset=utf-8',
        'SOAPAction'    => 'http://service.xxxxxx.com'
      }
      headers['cookie'] = @cookie unless @cookie.blank?

      uri                      = URI.parse(@url.to_s)
      request_http             = Net::HTTP.new(uri.host, uri.port)
      request_http.use_ssl     = uri.scheme.upcase == 'HTTPS'
      request_http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      request_http.ssl_version = :SSLv3

      pem = File.read(CONF_GW['cert_path'])
      request_http.cert = OpenSSL::X509::Certificate.new(pem)
      request_http.key  = OpenSSL::PKey::RSA.new(pem,'123456')

      Timeout::timeout(@timeout) {
        body = ""
        header = request_http.post(uri.path, post_data, headers) do |data|
          body << data
        end
        yield header,body
      }
    end

    def soap_http(method, params: {}, cookie: nil)
      @cookie = cookie
      
      post_data = resquest_to_xml(method, :hash => params)

      soap_login(method, post_data) do |header,body|
        puts "==#{method}== code   -- #{header.code}"        
        set_response_data(method,:header => header,:body => body) if header.code == '200'
        return self
      end
      nil
    end

    def resquest_to_xml(method, hash: {})
      hash_to_soap_xml(method, @response_type, hash)
    end

    def response_to_hash(method,xml_str)
      xml_to_hash(method,xml_str)
    end

    def set_response_data(method,header: nil, body: nil)
      @response_code = header.code
      @response_data = response_to_hash(method,body)
      @cookie        = header.response['set-cookie']
    end
  end
end


require 'cgi'

module EciticHttp
  module XMLUtil
    # hash to xml
    def to_request_xml(method,type,p={})
      require 'active_support/builder' unless defined?(Builder)
      xml = Builder::XmlMarkup.new(:indent=> p.size)
      xml.instruct!

      xml.message('method' => method, 'type' => type) do |node|
        p.each do |key,value|
          if key.to_sym == :dataSet && !value.blank?
            node.dataSet('count' => value.size) do |record_node|
              record_chind_node(value, record_node)
            end
          else
            node.tag! key,value
          end
        end
      end
    end
    def record_chind_node(dataSet,record_node)
      dataSet.each do |date|
        record_node.record date
      end
    end

    # hash to soap xml
    def hash_to_soap_xml(method,type,p={})
      xml = to_request_xml(method,type,p)
      puts xml
      data = <<-EOF
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                        xmlns:ser="http://service.xxxxxxxxx.com">
          <soapenv:Header/>
          <soapenv:Body>
              <ser:#{method}>
                  <ser:paraXML>#{CGI.escapeHTML(xml)}</ser:paraXML>
              </ser:#{method}>
          </soapenv:Body>
      </soapenv:Envelope>
      EOF

    end

    def xml_to_hash(method,xml_str)
      begin
        hash = Hash.from_xml(xml_str)

        loginReturn = hash['Envelope']['Body']["#{method}Response"]["#{method}Return"]

        dom = Nokogiri::XML(loginReturn,nil,'utf-8')
        node = dom.xpath('message').first
        hash = node.element_children.each_with_object(Hash.new) do |e, h|
          h[e.name.to_sym] = e.content
          if e.name.to_sym == :resParam || e.name.to_sym == :dataSet
            h[e.name.to_sym] = e.element_children.each_with_object(Hash.new) do |er, h|
              h[er.name.to_sym] = er.content
            end
          end
          if e.name.to_sym == :dataSet
            h[e.name.to_sym] = []
            e.element_children.each_with_object(Hash.new) do |er, hm|
              h[e.name.to_sym] << er.content
            end
          end
        end
        puts "---#{method}-----xml_to_hash--------"
        puts hash.inspect
        hash
      rescue Exception => e
        Rails.logger.info e.backtrace.join("\n")
        nil
      end
    end
  end
end




soap-ui 查看工具 调试特方便 记得到证书密码






分享到:
评论

相关推荐

    SSL证书生成软件、包括转换证书格式

    SSL证书生成软件、包括转换证书格式

    本地ssl证书生成工具

    下面将详细介绍如何生成本地SSL证书以及相关知识点。 1. SSL证书概述: SSL证书包含一个公钥和一个私钥,其中公钥用于加密数据,私钥用于解密。当用户访问一个网站时,浏览器会验证服务器的SSL证书,确保其来自...

    ssl证书生成工具(sha256算法)

    弱哈希算法签名的SSL证书(CVE-2004-2761)。 远程服务使用SSL证书链,该证书链已使用加密弱哈希算法(例如MD2、MD4、MD5或SHA1)签名。...该工具主要用于弱哈希算法签名的SSL证书升级成sha256算法签名证书。

    window下关于漏洞CVE-2004-2761,ssl证书制作工具

    而pvk2pfx.exe则用于将私钥和证书转换为PFX(个人信息交换)格式,这种格式是Windows系统中广泛接受的证书存储格式,便于导入和导出。 使用MakeCert.exe,你可以生成一个新的自签名证书,然后用SHA-256算法对其进行...

    利用OpenSSL命令进行SSL证书格式转换(Certificates Formats).docx

    PFX 证书是一种常见的证书格式,使用 OpenSSL 命令可以将 PEM 证书转换为 PFX 证书。命令如下: ``` openssl pkcs12 -export -out your_pfx_certificate.pfx -inkey laozuo.key -in laozuo.crt ``` 其中,`laozuo....

    SSL中各证书的转换

    本文将详细介绍如何在不同的证书格式之间进行转换,包括从`.cer`到`.jks`、从`.jks`到`.cer`、从`.p12`到`.pem`以及从`.cer`到`.pem`的过程。 ### 1. `.cer`格式转换至`.jks`格式 #### 背景介绍 `.cer`文件通常...

    Tomcat更换SSL证书方法(jks与pfx转换)

    为了能够使用JWSDP工具包中的工具进行证书转换,需要下载并安装`jwsdp-2_0-windows-i586.exe`。该工具包包含了用于PFX转JKS所需的命令行工具。 #### 创建JKS Keystore文件 接下来,需要使用`keytool`命令创建一个...

    ssl证书生成图形化工具.zip

    本文将详细介绍“ssl证书生成图形化工具.zip”中的关键知识点,包括SSL证书、XCA工具、证书生成流程以及HTTPS协议。 SSL(Secure Socket Layer)证书是数字证书的一种,它通过公钥和私钥对网络通信进行加密,为用户...

    ssl证书生成工具解决弱哈希算法签名的SSL证书(CVE-2004-2761)

    远程服务使用SSL证书链,该证书链已使用加密弱哈希算法(例如MD2、MD4、MD5或SHA1)签名。这些签名算法很容易受到碰撞攻击。攻击者可以利用这一点生成另一个具有相同数字签名的证书,从而允许攻击者伪装成受影响的服务...

    ssl证书批量生成工具

    SSL证书批量生成工具是一种用于快速、高效地创建多个SSL(Secure Sockets Layer)证书的软件。在网络安全领域,SSL证书是保障网站数据传输安全的重要组件,它通过加密连接确保用户与服务器之间的通信不被第三方窃取...

    本地生成SSL证书工具CreateCertGUICreateCertGUI

    SSL证书是验证网站身份的关键工具,通常由受信任的证书颁发机构(CA)签发。然而,在本地开发环境中,我们可能需要自签发的SSL证书来测试HTTPS连接,这时就用到了"CreateCertGUI"这样的工具。 "CreateCertGUI"是一...

    ZABBIX监控SSL证书过期时间的监控工具-sslooker

    2. **合规性**:许多行业标准和法规要求网站和服务必须使用有效的SSL证书,监控可确保合规性。 3. **业务连续性**:证书过期会导致服务中断,可能影响用户体验和业务运营。 4. **提前规划**:提前知道证书何时到期...

    PHPStudy(小皮)ssl证书批量替换工具

    **PHPStudy SSL证书批量替换工具** 在互联网领域,安全通信是至关重要的,特别是对于那些处理敏感数据的网站。SSL(Secure Socket Layer)证书是确保网站数据传输加密的关键元素,它通过建立安全的HTTPS连接来保护...

    jks证书格式转换nginx使用格式

    由于生成的证书是jks格式,nginx不能直接用,需要要转成PEM格式,这要用到jks2pfx工具进行转换。 jks2pfx的命令格式:JKS2PFX.bat keystore password alias exportname keystore:KeyStore文件绝对路径 password:...

    portecle 证书格式转换

    **SSL证书格式转换详解** 在数字证书领域,SSL(Secure ...通过上述步骤,你可以轻松地将证书转换为适应Android系统的格式,确保应用的网络通信安全。在实际操作中,务必遵循最佳安全实践,确保数据的完整性和保密性。

    keystoke证书转换nginx证书工具

    标题提到的"keystoke证书转换nginx证书工具"是一个帮助管理员处理SSL/TLS证书的实用程序,特别针对从Java的`keytool.exe`生成的`.keystore`格式证书进行转换。`keytool`是Java Development Kit (JDK) 自带的一个...

    Linux 生成SSL证书 供 nginx使用

    Linux 生成 SSL 证书供 nginx 使用是指通过 OpenSSL 命令生成 SSL 证书的过程,这个过程包括生成私钥、证书请求文件、证书文件和配置 nginx 使用证书。 首先,生成私钥文件使用以下命令:`openssl genrsa -des3 -...

    JDK生成ssl证书

    ### JDK生成SSL证书详解 #### 一、概述 ...至此,我们已经完成了使用JDK自带工具`keytool`生成并配置SSL证书的全过程。接下来,您可以通过HTTPS端口8443访问您的服务器,实现数据传输的安全加密。

    关于生成SSL数字证书的总结

    关于生成SSL数字证书的总结 在本文中,我们将详细介绍如何生成SSL数字证书,并在Tomcat服务器上配置SSL数字证书。同时,我们还将总结一些常见的问题和解决方法。 一、生成SSL数字证书 为了生成SSL数字证书,我们...

    证书转换生成工具protecle

    1. **P12到BKS转换**:在Android开发中,如果需要在设备上使用私钥进行SSL连接或者存储客户端证书,通常需要将P12格式的证书转换为BKS格式。Protecle提供了一键式转换功能,只需导入P12文件,设置密码,然后导出为...

Global site tag (gtag.js) - Google Analytics