我想确保在SSL证书无效时正确配置客户端库(当前使用Python,Ruby,PHP,Java和.NET)并且失败.Shmatikov的论文,世界上最危险的代码:在非浏览器软件中验证SSL证书,揭示了SSL验证的混乱程度,因此我想彻底测试可能的失败.
根据研究,证书无效,如果:
理想情况下,我认为每个无效案例都会有一个测试用例.为此,我目前正在测试HTTP访问过的网站HTTPS,这导致我可以在测试中验证失败,如下所示:
self.assertRaises(SSLHandshakeError, lambda: api.call_to_unmatched_hostname())
Run Code Online (Sandbox Code Playgroud)
这是不完整的(仅涵盖一个案例)并且可能是错误的,所以...
如何测试非浏览器软件是否正确验证了SSL证书?
我目前正在尝试使用Android的新构建系统(http://tools.android.com/tech-docs/new-build-system/using-the-new-build-system).因此我创建了一个build.gradle包含以下内容的文件:
apply plugin: 'android'
android {
compileSdkVersion 15
target='android-15'
defaultConfig {
targetSdkVersion 15
minSdkVersion 8
versionCode 10
}
sourceSets {
main {
manifest {
srcFile 'AndroidManifest.xml'
}
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.android:android:4.0.1.2'
compile project(':ActionBarSherlock')
compile fileTree(dir: './libs', include: '*.jar')
}
Run Code Online (Sandbox Code Playgroud)
我是根据文档完成的,所以我希望它可以工作; 但是,我收到以下错误消息:
错误:默认配置与Android API级别14间接依赖,但变体'Debug'的minSdkVersion是API级别8
当删除对android 4.0.1.2的显式依赖时,错误消失,但由于Android文件本身无法解析,因此遗留了编译错误.例如,Activity或者View无法找到类.据说,我可以降级到旧版本的Android来匹配minSdkVersion,但我想15用最少的sdk编译8.
插件本身在版本为0.3的root build.gradle中声明.
你有谁知道如何解决这个错误?
谢谢,马蒂亚斯
我的模型如下:
class User
include Mongoid::Document
field :name
end
Run Code Online (Sandbox Code Playgroud)
将一些用户对象保存到数据库后,我添加了更多字段:
class User
include Mongoid::Document
include Mongoid::Timestamps::Created
field :name
field :birthdate
end
Run Code Online (Sandbox Code Playgroud)
现在,我希望可以使用以下代码片段:
@user = User.all
@user.each do |u|
puts u.name
puts u.birthdate.strftime(#someFormat)
puts u.created_at.strftime(#someFormat)
end
Run Code Online (Sandbox Code Playgroud)
不幸的是,因为我的旧user对象没有birthdate密钥,所以我收到此错误:strftime called on nil class。
问题:
created_at因为旧数据也没有该字段。我正在寻找解决此问题的好方法,nil每次检查条件不是一个可扩展的选项,因为字段的数量将继续增加。
I use devise for API authentication. I have overwritten SessionController:create method like this:
class Users::SessionsController < Devise::SessionsController
def create
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
set_flash_message(:notice, :signed_in) if is_navigational_format?
val = sign_in(resource_name, resource)
current_user.reset_authentication_token!
respond_to do |format|
format.html do
respond_with resource, :location => redirect_location(resource_name, resource)
end
format.json do
render :json => { :status => OK_OK, :auth_token => current_user.authentication_token }.to_json, :status => :ok
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
As you can see I respond with a status code when authenticating …
我正在开发一个应用程序,当用户使用区域监控靠近某些地标时会提醒用户.一切正常,但当应用程序在后台时,我没有收到警报.当我打开应用程序时,我会弹出所有警报.我想要的是在应用程序处于后台时获取它们.我想知道是否可能或应用程序是否需要运行以获取警报?任何帮助将不胜感激.
更新:问题似乎是我使用了警报而不是本地通知.这是我使用的代码:
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
NSLog(@"Entered Region - %@", region.identifier);
[self showRegionAlert:@"You are near: " forRegion:region.identifier];
}
Run Code Online (Sandbox Code Playgroud)
如何将其更改为本地通知?
我试图让Toopher使用SSH,我遇到了这个错误:
Not a valid OAuth signed request. See http://oauth.net to learn more.
Run Code Online (Sandbox Code Playgroud)
提前致谢!
编辑:这是一个虚拟机计时错误.谢谢!
我有一个div,我想设置为其父容器宽度的90%,我希望设置它的高度,以达到特定的宽高比,比如说3:1.
.mydiv {
width: 90%
height: 30%(of-width);
}
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点,不涉及JavaScript?
我从另一个地方复制了这一行:
Total += parseFloat($(this).val())|0;
Run Code Online (Sandbox Code Playgroud)
操作员的功能是|什么?当我改变数字时,我会得到不同的结果.