Tag: openssl

如何解决OpenSSL :: Cipher :: Cipher#encrypt的弃用警告

我刚刚将我的Mac升级到Snow Leopard并启动并运行了我的Rails环境。 唯一的区别 – OSX除了 – 我以前的安装是我现在运行ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0] (Snow Leopard默认)而不是1.8.6 。 我现在在运行代码时看到与OpenSSL相关的弃用警告: warning: argumtents for OpenSSL::Cipher::Cipher#encrypt and OpenSSL::Cipher::Cipher#decrypt were deprecated; use OpenSSL::Cipher::Cipher#pkcs5_keyivgen to derive key and IV 在第4行引起这些警告(它解码加密字符串)的代码示例: 1. def decrypt(data) 2. encryptor = OpenSSL::Cipher::Cipher.new(‘DES-EDE3-CBC’) 3. key = “my key” 4. encryptor.decrypt(key) 5. text = encryptor.update(data) 6. text << encryptor.final 7. […]

rails加密/解密

我需要在我的rails应用程序中进行加密和解密。 我试图使用ezcrypto,但每当我解密时,我都会收到此错误。 OpenSSL::Cipher::CipherError in ProfilesController#show wrong final block length 需要更改什么才能阻止此错误。 我尝试使用这样的另一个openssl实现(从我的模型中调用的方法) def encrypt_attr(unencrypted) c = OpenSSL::Cipher.new(“aes-256-cbc”) c.encrypt c.key = Digest::SHA1.hexdigest(‘pass’) e = c.update(unencrypted) e << c.final return e end def decrypt_attr(encrypted_attr) if encrypted_attr != "" c = OpenSSL::Cipher::Cipher.new("aes-256-cbc") c.decrypt c.key = Digest::SHA1.hexdigest('pass') d = c.update(encrypted_attr) d << c.final return d end end 它会在解密时抛出完全相同的错误。 我应该如何进行加密和解密,而不是出现这个openssl错误。

使用Ruby on Rails签署iPhone配置XML配置文件

我正在生成一个有效的iPhone配置XML配置文件,并通过Rails页面提供它。 我试图弄清楚如何使用x509证书以编程方式对XML文件进行签名,以便iPhone将其识别为签名的配置文件 这是关于签署iPhone配置文件所涉及内容的一个很好的教程http://www.rootmanager.com/iphone-ota-configuration/iphone-ota-setup-with-signed-mobileconfig.html 具体来说,在命令行上执行此操作将对未签名文件company.mobileconfig进行签名 openssl smime -sign -in company.mobileconfig -out signed.mobileconfig -signer server.crt -inkey server.key -certfile cert-chain.crt -outform der -nodetach 假设我在字符串中有XML文件,那么Ruby on Rails中的等效命令会是什么? 我可以找到很多关于通过带有rails的SSL连接提供内容的文档,但是在交付之前没有很多关于签署任意内容的文档。

Ruby和“你必须使用OpenSSL支持重新编译Ruby或更改Gemfile中的源代码”

使用rvm我将我的ruby升级到1.9.3-p392,同时添加了2.0.0,当我运行我的bundle命令时尝试使用这个版本时我得到了这个错误。 Could not load OpenSSL. You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from ‘https’ to ‘http’. Instructions for compiling with OpenSSL using RVM are available at rvm.io/packages/openssl. 我已经按照几个不同的说明来解决这个问题。 我试过删除版本并使用rvm选项安装它 –with-openssl-dir=$HOME/.rvm/usr 我已经安装了带有rvm和macports的OpenSSL。 两者都没有帮助解决这个问题。 我甚至使用以下方法更改了ssl证书的文件位置: export SSL_CERT_FILE=/Users/DarkLord/.rvm/usr/ssl/cert.pem 无论我做什么,我都会继续犯错误。 有人可以帮我解决这个问题吗?

OpenSSL,RVM,Brew,冲突错误

当我在终端运行brew医生时:我收到以下错误: Warning: Some keg-only formula are linked into the Cellar. You may wish to `brew unlink` these brews: openssl 如果我取消链接,并输入rvm要求 :我将得到以下错误。 Checking requirements for osx. dyld: Library not loaded: @@HOMEBREW_CELLAR@@/openssl/1.0.1f/lib/libssl.1.0.0.dylib Referenced from: /usr/local/opt/openssl/bin/openssl Reason: image not found Failed reading certificates path for ‘/usr/local/opt/openssl/bin/openssl’ with return code: (). RVM autolibs is now configured with mode ‘2’ […]

OpenSSL :: SSL :: SSLContext SNI servername_cb不工作

正如在OpenSSL :: X509 ::证书显示错误域证书中所引用的那样,我需要使用TLSv1或更高版本以及 服务器名称指示扩展。 即使通过SSLContext设置了ssl_version和servername_cb ,我仍然会获得myproair.com的错误证书。 begin timeout(1) do tcp_client = TCPSocket.new(“#{instance[“domain”]}”, 443) ssl_context = OpenSSL::SSL::SSLContext.new() ssl_context.ssl_version = :TLSv1 ssl_context.servername_cb = “https://#{instance[“domain”]}” ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_client, ssl_context) ssl_client.connect cert = OpenSSL::X509::Certificate.new(ssl_client.peer_cert) ssl_client.sysclose tcp_client.close #http://ruby-doc.org/stdlib-2.0/libdoc/openssl/rdoc/OpenSSL/X509/Certificate.html date = Date.parse((cert.not_after).to_s) row.push(“#{date.strftime(‘%F’)} #{cert.signature_algorithm} #{cert.subject.to_a.select{|name, _, _| name == ‘CN’ }.first[1]}”.downcase.ljust(57)) end rescue SocketError row.push(“down”.ljust(57)) rescue Errno::ECONNREFUSED row.push(“connection refused”.ljust(57)) rescue […]

无法安装gem,因为“未定义的方法`invoke_with_build_args’代表nil:NilClass”

我在Ruby轨道上,我正处于Ruby on Rails的安装过程中。 我正在尝试安装gem,但它没有发生,我不知道为什么以及如何解决它。 $gem install bundler ERROR: Loading command: install (LoadError) dlopen(/Users/nthulanemakgato/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64- darwin13.0/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Referenced from: /Users/nthulanemakgato/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64- darwin13.0/openssl.bundle Reason: image not found – /Users/nthulanemakgato/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle ERROR: While executing gem … (NoMethodError) undefined method `invoke_with_build_args’ for nil:NilClass 这是我尝试过的解决方案之一: $CONFIGURE_OPTS=”–with-openssl-dir=brew –prefix openssl” rbenv install 2.1.1 rbenv: /Users/nthulanemakgato/.rbenv/versions/2.1.1 already exists continue with installation? (y/N) […]

使用rubygem访问Shopify API时出现SSL_connect错误

我使用shopify_api gem访问Shopify API时遇到问题。 这是发生的事情: >> require “shopify_api” #=> false >> ShopifyAPI::Base.site = “https://username:secret@mysite.myshopify.com/admin” => “https://username:secret@mysite.myshopify.com/admin” >> products = ShopifyAPI::Product.find(:all) Errno::ECONNRESET: Connection reset by peer – SSL_connect from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `connect’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `block in connect’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:54:in `timeout’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:99:in `timeout’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `connect’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:755:in `do_start’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:744:in `start’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1284:in `request’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1026:in `get’ […]

无法在OSX上运行带有RVM的Ruby 2.2.3

我有两部MacBook(一部在小牛队,另一部在优胜美地),同样的事情发生在两者上。 使用RVM安装Ruby 2.2.3后,出现以下错误: .rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:923:in `connect’: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::SSLError) 我曾尝试在线搜索解决方案,但似乎没有任何效果。 大多数有此问题的人都在运行Windows机器。 $ rvm osx-ssl-certs status all Certificates for /usr/local/etc/openssl/cert.pem: Up to date. Certificates for /etc/openssl/cert.pem: Up to date. 切换回2.2.2工作正常。 有什么想法吗?

“SSL_connect返回= 1 errno = 0状态= SSLv3读取服务器证书B:证书validation失败”

我正在设置Redmine来通过IMAP从gmail中查询电子邮件。 尝试运行适当的Ruby任务会导致以下错误: SSL_connect返回= 1 errno = 0状态= SSLv3读取服务器证书B:证书validation失败 当Ruby尝试通过OpenSSL连接imap.gmail.com时出现错误,如下代码行: imap = Net::IMAP.new(host, port, ssl) 当我尝试从OpenSSL命令行连接上述主机时,它成功连接。 我知道Ruby没有找到一些证书,我看到了各种解决方案提案,但不幸的是我仍然无法弄清楚如何解决这个问题(我不使用rvm)。 我试图通过设置OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE来禁用validation,但得到“动态常量赋值”错误。 我的环境: Linux debianvm 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2+deb7u2 x86_64 GNU/Linux root@debianvm:~# ruby –version ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-linux] root@debianvm:~# rails –version Rails 3.2.13