{"id":21656980,"url":"https://github.com/cotag/ruby-tls","last_synced_at":"2025-04-11T22:12:38.013Z","repository":{"id":56893707,"uuid":"14578936","full_name":"cotag/ruby-tls","owner":"cotag","description":"Generic TLS for ruby","archived":false,"fork":false,"pushed_at":"2024-02-29T04:12:16.000Z","size":83,"stargazers_count":6,"open_issues_count":5,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-11T22:12:33.027Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cotag.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-11-21T05:43:35.000Z","updated_at":"2024-02-28T12:49:30.000Z","dependencies_parsed_at":"2024-11-25T09:18:46.306Z","dependency_job_id":"731eb689-acee-48d8-945e-06df548b55b0","html_url":"https://github.com/cotag/ruby-tls","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotag%2Fruby-tls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotag%2Fruby-tls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotag%2Fruby-tls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotag%2Fruby-tls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cotag","download_url":"https://codeload.github.com/cotag/ruby-tls/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248487683,"owners_count":21112190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T09:18:35.193Z","updated_at":"2025-04-11T22:12:37.990Z","avatar_url":"https://github.com/cotag.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ruby-tls\n\nRuby-TLS decouples the management of encrypted communications, putting you in charge of the transport layer. It can be used as an alternative to Ruby's SSLSocket.\n\n[![Build Status](https://travis-ci.org/cotag/ruby-tls.svg?branch=master)](https://travis-ci.org/cotag/ruby-tls)\n\n\n## Install the gem\n\nInstall it with [RubyGems](https://rubygems.org/)\n\n    gem install ruby-tls\n\nor add this to your Gemfile if you use [Bundler](http://gembundler.com/):\n\n    gem \"ruby-tls\"\n\n\nWindows users will require an installation of OpenSSL (32bit or 64bit matching the Ruby installation)\n\n\n## Usage\n\n```ruby\nrequire 'rubygems'\nrequire 'ruby-tls'\n\nclass transport\n  def initialize\n    is_server = true\n    callback_obj = self\n    options = {\n      verify_peer: true,\n      private_key: '/file/path.pem',\n      cert_chain: '/file/path.crt',\n      ciphers: 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!CAMELLIA:@STRENGTH' # (default)\n      # protocols: [\"h2\", \"http/1.1\"], # Can be used where OpenSSL \u003e= 1.0.2 (Application Level Protocol negotiation)\n      # fallback: \"http/1.1\", # Optional fallback to a default protocol when either client or server doesn't support ALPN\n      # client_ca: '/file/path.pem'\n    }\n    @ssl_layer = RubyTls::SSL::Box.new(is_server, callback_obj, options)\n  end\n\n  def close_cb\n    puts \"The transport layer should be shutdown\"\n  end\n\n  def dispatch_cb(data)\n    puts \"Clear text data that has been decrypted\"\n  end\n\n  def transmit_cb(data)\n    puts \"Encrypted data for transmission to remote\"\n    # @tcp.send data\n  end\n\n  def handshake_cb(protocol)\n    puts \"initial handshake has completed\"\n  end\n\n  def verify_cb(cert)\n    # Return true or false\n    is_cert_valid? cert\n  end\n\n  def start_tls\n    # Start SSL negotiation when you are ready\n    @ssl_layer.start\n  end\n\n  def send(data)\n    @ssl_layer.encrypt(data)\n  end\nend\n\n#\n# Create a new TLS connection\n#\nconnection = transport.new\n\n#\n# Init the handshake\n#\nconnection.start_tls\n\n#\n# Start sending data to the remote, this will trigger the\n# transmit_cb with encrypted data to send.\n#\nconnection.send('client request')\n\n#\n# Similarly when data is received from the remote it should be\n# passed to connection.decrypt where the dispatch_cb will be\n# called with clear text\n#\n```\n\n\n## License and copyright\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcotag%2Fruby-tls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcotag%2Fruby-tls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcotag%2Fruby-tls/lists"}