I am getting an error with my ruby on rails application.
I am trying to use this repository :https://github.com/nomad/dubai to generate a pkpass.
However, I am getting a pcks12Error::Mac verify failure at this step:
Dubai::Passbook.certificate, Dubai::Passbook.password = "/resources/certificate.p12", "mypassword"
# Example.pass is a directory with files "pass.json", "icon.png" & "icon#2x.png"
File.open("Example.pkpass", 'w') do |f|
f.write Dubai::Passbook::Pass.new("Example.pass").pkpass.string
end
I looked on the web but founded nothing about this kind of error in RoR.
EDIT:
I am pretty sure that this is an OpenSSL error. My certificates are coming from another machine. Is that thing can influence this error? Do I have to create a certificate on my machine? To configure OpenSSL?
I founded the answer by myself.
In the Dubai gem, you just have to change the read() by a binread().
It solved my mac verify failure.
Related
Two days ago, I started seeing this error on the production server of my app (on staging everything works fine). I found a lot of topics here on SO, but none of them solved this issue for me.
Here's the piece of code that's causing this error message:
#client = Savon.client(wsdl: wsdl_url)
##client = Savon.client(wsdl: wsdl_url, ssl_verify_mode: :none) # this sovles the problem, but I don't want to skip the verification
On SO, I also found that a possible solution might be to create an initializer file and put there the following:
require 'open-uri'
require 'net/https'
module Net
class HTTP
alias_method :original_use_ssl=, :use_ssl=
def use_ssl=(flag)
#self.ca_path = Rails.root.join('lib/ca-bundle.crt').to_s
self.ssl_version = :TLSv1_2 # added
self.ca_file = '/etc/ssl/certs/ca-certificates.crt' # the file exists
self.verify_mode = OpenSSL::SSL::VERIFY_PEER
self.original_use_ssl = flag
end
end
end
But this, unfortunately, didn't solve the error. I also tried to reinstall the certificate on the production Ubuntu (14.04) server
sudo apt-get install openssl ca-certificates
The package has been upgraded, but the error is unfortunately still here.
Any tips what could I do yet and get rid of the error?
EDIT: How or where should I start debugging?
Run openssl s_client -showcerts -connect server_you_are_connecting_to.com:443 and examine the certificate. After this you should find yourself in one of the following situations:
The certificate is valid (has valid expiry date and common name), but it is signed by the certificate authority (CA) that isn't trusted by your system. If that's the case, you would need to add the CA's certificate to the trusted store or update the ca-bundle package on your system.
The certificate is invalid (is expired or has the wrong common name). If disabling peer SSL certificate verification isn't an option for you, then you can implement your own certificate verification callback, for example as described here -- in this case the code wouldn't be relying on system's trusted store, but rather check that the peer server uses a specific certificate.
Hope this helps.
I also started getting this error a few days ago.
Removing geocoder fixed the issue.
Per Heroku support, sometimes these errors occur when an external provider changes their SSL configuration.
Reply to comment:
Nothing in logs specifically saying geocoder, but I saw in my error reports (via exception notifier gem) that the app crashed, with this error, on lines making a request to geocoder.
I also had a callback on the users model, and noticed the app crashed anytime a user was saved/updated.
Lucky guess I suppose.
Trying to run a project that was provided by a client.
I have the correct versions of Ruby, Gems, Rails, Bundler, Homebrew etc installed.
When I run rails server I get the following error in terminal.
.rvm/gems/ruby-2.2.2/gems/airbrake-ruby-1.0.4/lib/airbrake-ruby.rb:288:in `call_notifier': the 'default' notifier isn't configured (Airbrake::Error)
After much time spent on Google I couldn't find a fix on this.
Here is a screenshot of the whole terminal error message which I get the feeling these other lines could be related.
It looks like a previous developer may have hardcoded a commit hook in the application, pointing to a file in their local .git folder (and which you don't have).
I'd recommend either asking the developer to provide the missing file, create a dummy file in the same place, or removing that line.
I have the problem that my development machine does not want to connect to my IMAP accounts any more. I know I must have changed something, but cannot think of anything relevant. But what I found is, that with ruby 2.1.0 and 2.1.2 my application works, but with 2.1.5 and 2.2.1 [edit: 2.2.2 failing, too] it does not work.
So I started debugging and extracted the parts that actually connect and throw the SSL error. The shortened script is the following:
require 'net/imap'
#imap = nil
begin
#imap = Net::IMAP.new("mail.example.com", {port: 143})
#imap.starttls({}, true)
#imap.login("username", "password")
rescue => e
puts e
end
The result with 2.0.0 and 2.1.2 is empty, so it worked. But with 2.1.5 and 2.2.1 [edit: and 2.2.2] I get the following error:
SSL_write: certificate verify failed
Of course I immediately checked the server's keychain, but it seems okay. It results in
Verify return code: 0 (ok)
though it has the line
verify error:num=20:unable to get local issuer certificate
but I read that this error is "normal". I cannot explain this error, as I included the certificates correctly with my dovecot server, but when searching the web it looks like everyone else is getting this line with most certificates, too, and it works. Also, like mentioned before, the verify return code is 0, so everything should work.
Do you have an idea if this is a problem with the mentioned line or if it's a bug with newer ruby versions? I could not find any clear search results regarding this.
PS: I need to use starttls, "ssl: true" gives me an unknown protocol error, as I enabled tls only.
edit2: I re-checked again. On the production server, 2.1.5 works. Could it be a problem with CA certificates on the development server or something? But why do older versions work then and newer don't?
--- edit: output as requested ---
I changed my real domain to domain.com in the bin. The host is a sub domain and the certificate a subdomain wildcard certificate from RapidSSL (*.domain.com).
http://pastebin.com/9BGK4w1w
Finally solved it by reinstalling OS X. For some reason it was a problem with my system, though I triple-checked everything from OpenSSL to rvm, Ruby, system-wide installed authority certificates and so on.
Thanks for your help :-)
I'm attempting to host my rails app on a vps. The issue that I'm running into is when I try to navigate to my rails app, I get the following error message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
When I check out the virtual server's error log it tells me the following:
Premature end of script headers:
And sometimes that's followed with a feed or a contact or a referer: myurl.com/ or nothing at all.
I've seen plenty of posts regarding this error messages elsewhere but none so far have resolved the matter. The general consensus seems to be that it likely has to do with the rails environment variable or file.
As this is my first attempt at putting a rails app on a production server, I figure this is plausible. Below is my environment.rb
cat config/environment.rb
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
As for the server, I'm using Ubuntu 12.04 with Webmin/Virtualmin and apache2 with passenger. Ruby 2.1.5p273 was installed using RVM and all gems are up to date.
Any thoughts would be helpful!
Today I was confronted with exactly the same problem. In my case it was the line 'secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>' in config/secrets.yml (but the env variable was not defined on the server). Please, look in ยง3.3 of http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html.
I am using Rails 4.1 and Ruby 2.1.1 on Ubuntu.
My application is running just fine on the local development environment. When I moved everything to the production environment server, and tried the application URL, I got the following:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
The log file (production.log) has in it something about the migrations, but nothing else.
Where do I get started trying to figure out what this is about?
From original poster:
I followed the instructions and set up an environment variable for the secret_key. It turns out Rails 4.1 cannot read it and this seems to be a known issue. So, I had to put the key directly into secrets.yml and this solved the problem