简体   繁体   中英

Setup Rails 4 SSL Webrick localhost to work with iOS 9

First I followed this http://underthehood.carwow.co.uk/httpsssl-in-your-local-rails-4-1-development-environment/ to make my rails app accept https requests, which works fine doing a GET from the browser. The only thing I couldn't do was adding localhost.crt to the system certificates (step 3 in my link). When I try dragging it, it asks for my password, but when I start typing, it's like my keyboard is disabled, I can't type anything.

But when I try accessing it from n iPhone 6s simulator (iOS 9), it doesn't work.

Error in the server:

ERROR OpenSSL::SSL::SSLError: SSL_accept returned=1 errno=0 state=error: no shared cipher
/Users/rodrigoruiz/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/openssl/ssl.rb:236:in `accept'

Error in the client (iPhone simulator):

Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9824, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x7fd0dab15a80 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9824, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9824}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://localhost:3000/login_with_facebook.json, NSErrorFailingURLStringKey=https://localhost:3000/login_with_facebook.json, _kCFStreamErrorDomainKey=3}

How do I solve this?

Try dragging & dropping the certificate file, localhost.crt , into the Simulator.

See: https://stackoverflow.com/a/20047835/242933

UPDATE in response to your comment:

I don't see the pictures from step three. I don't remember having to enter a password. Try generating localhost.crt from inside a directory on your desktop. Don't use sudo . Then, drag localhost.crt from the directory on your desktop (not from Keychain Access) into your iPhone Simulator.

Here's the script (named create_self-signed_ssl_certificate.sh ) I used to generate my certificate, which I named server.crt instead of localhost.crt .

#!/bin/sh

# Create a Self-Signed SSL Certificate
openssl genrsa -aes256 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
rm server.pass.key
openssl req -new -sha256 -key server.key -out server.csr -subj /CN=localhost
openssl x509 -req -sha512 -days 365 -in server.csr -signkey server.key -out server.crt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM