我使用"NSMutableURLRequest"租用自签名证书,当使用带有"SecTrustSetAnchorCertificates"的自定义证书锚定证书时,iOS 11失败并显示以下错误消息:
refreshPreferences: HangTracerEnabled: 1
refreshPreferences: HangTracerDuration: 500
refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0
ATS failed system trust
System Trust failed for [1:0x1c417dc40]
TIC SSL Trust Error [1:0x1c417dc40]: 3:0
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
Task <721D712D-FDBD-4F52-8C9F-EEEA28104E73>.<1> HTTP load failed (error code: -1200 [3:-9802])
Task <721D712D-FDBD-4F52-8C9F-EEEA28104E73>.<1> finished with error - code: -1200
Run Code Online (Sandbox Code Playgroud)
以前适用于iOS 10的内容在IO 11中不再有效.
我知道iOS 11不再支持以下内容:
除了一个SHA-1指纹外,证书不使用这些,但也列出了SHA-256指纹.
通过添加以下内容,我们可以绕过ATS(App Transport Security)错误:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>mydomain.com</key>
<dict>
<!--Include …Run Code Online (Sandbox Code Playgroud) 打开特定项目打开特定项目时,Xcode会重复崩溃.
打开另一个项目似乎很好.触摸条似乎正在产生一些问题.关于如何解决这个问题的任何想法.
在没有触摸条的情况下在不同的MacBook上打开项目似乎很好.
从日志中我可以看到这与NSTouchBarFinder和IDE不符合KVO有关?
我一直收到这个崩溃日志:
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
ProductBuildVersion: 9A1004
UNCAUGHT EXCEPTION (NSInternalInconsistencyException): Cannot update for observer <NSTouchBarFinder 0x7fee281263e0> for the key path "_keyWindow.firstResponder" from <IDEApplication 0x7fee22f0b1c0>, most likely because the value for the key "_keyWindow" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the IDEApplication class.
UserInfo: (null)
Hints:
Backtrace:
0 __exceptionPreprocess (in …Run Code Online (Sandbox Code Playgroud) 我试图将 GoLang "Go" 与 gRPC 一起理解,并使简单的服务可扩展。
假设我有一个 client1 调用 service1(添加数字),该 service1 调用 service2(确定结果是否为素数),并且 service2 将结果返回给 service1,然后 service1 将结果全部通过 gRPC 返回给 client1。
当我使用协议缓冲区“proto3”并通过 protoc 生成 Go 代码时。我得到了以一种特定方式调用服务的生成方法。我认为异步调用方法“Go”没有区别。
并且底层调用似乎是“调用”,我认为它是同步的,一旦接收到结果,调用就会返回。
如何使 service1 成为“高性能”,我知道我可以在集群中运行它并拥有副本,但这意味着我只能根据集群中的实例数量为客户端提供服务。
我想要一个“单一”服务能够为多个客户端(例如 1000)提供服务。
这是一个简单的服务器,我不确定这是否有效:我确实知道该getprime功能每次都会拨号,并且可能会移动它以使此拨号持续并重新使用;但更重要的是我想制作一个简单的高性能可扩展服务并得到一个很好的理解。
(A) 也许整个设计是不正确的,service1 应该在收到指令“ack”后立即返回,进行加法并将下一个请求发送到 sercice2,以确定答案是否为质数;再次 service2 只是响应收到请求的确认。一旦服务 2 确定了素数,就会向客户端发出呼叫并得到答复。
如果上面的(A)是更好的方法,那么仍然请解释下面的瓶颈;处理多个客户端时会发生什么?对“Listen”的调用做了什么,“阻塞或不阻塞”等。
package main
import (
pb "demo/internal/pkg/proto_gen/calc"
"fmt"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"log"
"net"
)
const (
port = ":8080"
)
type service struct {
}
func (s *service) Calculate(ctx context.Context, req *pb.Instruction) (*pb.Response, error) {
var answer …Run Code Online (Sandbox Code Playgroud) 我一直在尝试让 JWT 身份验证工作,但并不完全清楚这需要如何完成,以及在 ASP.NET Core 3.1 中执行此操作的最佳方法是什么。
我使用的是基于 Cookie 的身份验证,我认为它与会话 ID 相关联,而会话 ID 与正在运行的服务器实例相关联。如果我想使用具有不同 IP 地址和端口的多个服务器,我假设 cookie 将不再起作用,因此需要其他可以跨系统验证的东西。
我一直在关注各种网络示例,但不清楚一旦用户通过“身份验证” - 登录后我拥有 JWT 令牌,该怎么做。一旦用户登录,他们就可以通过以下方式访问系统的任何部分:html 链接(菜单)。
如何在所有后续请求中传递令牌?
在用户通过身份验证并将令牌存储在浏览器 sessionStore 或 localStorage 或 Cookie 中后,我是否将用户重定向到欢迎页面?处理这种情况的最佳方法是什么。
options.success = function (obj) {
sessionStorage.setItem("token", obj.token);
sessionStorage.setItem("userName",$("#userName").val());
}
Run Code Online (Sandbox Code Playgroud)
HTTP 标头
请问授权HTTP标头变量工作,并会在这所有后续请求由浏览器发送各地,作为HTTP客户端。这个 HTTP 标头持续多久,一旦 TCP 套接字关闭,它会丢失吗?如何在 ASP.NET Core 3.1 中设置此 HTTP 标头变量?然后服务器会使用这个 Header 来验证令牌,并再次传递它以在后续请求中使用吗?
目前我有这个,一旦用户通过身份验证,它就会返回正文中的令牌:
var claims = await GetClaims(user);
var token = GenerateSecurityToken(claims);
return Ok(new { Token = token })
Run Code Online (Sandbox Code Playgroud)
AJAX …
我正在尝试添加一些基于自定义角色authorisation,但无法将启动配置为调用我的AuthorizationHandler.
我在GitHub上找到了一些相关信息:这里。这是一个错误吗?
我正在使用ASP.NET Core 3.1并且我的初始化如下:
1:这使用 Dapper ORM 从数据库检索 url/角色:
private List<UrlRole> GetRolesRoutes()
{
var urlRole = DapperORM.ReturnList<UrlRole>("user_url_role_all");
return urlRole.Result.ToList();
}
Run Code Online (Sandbox Code Playgroud)
2:在我的 Startup 中,我获取 url/roles 并将结果存储在全局变量中:
public Startup(IConfiguration configuration, IWebHostEnvironment env)
{
this.environment = env;
UrlRoles = GetRolesRoutes();
}
Run Code Online (Sandbox Code Playgroud)
3:我的配置是:注意UrlRoles传递的配置
public void ConfigureServices(IServiceCollection services)
{
// .. snip
services.AddAuthorization(o =>
o.AddPolicy(_RequireAuthenticatedUserPolicy,
builder => builder.RequireAuthenticatedUser()));
services.AddAuthorization(options =>
{
options.AddPolicy("Roles", policy =>
policy.Requirements.Add(new UrlRolesRequirement(UrlRoles)));
});
services.AddSingleton<AuthorizationHandler<UrlRolesRequirement>, PermissionHandler>();
} …Run Code Online (Sandbox Code Playgroud) 我正在使用多模块 pom 设置,当使用发布插件时,我无法这样做。我收到错误:
Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:prepare (default-cli) on project libraryparent: Can't release project due to non released dependencies :
com.xyz:libraryparent:pom:1.1-SNAPSHOT
in project 'utils' (com.xyz:utils:jar:1.1-SNAPSHOT)
Run Code Online (Sandbox Code Playgroud)
我运行的命令是:
mvn -B release:clean release:prepare release:perform -DdryRun=true -DdevelopmentVersion=1.2-SNAPSHOT -DreleaseVersion=1.1
Run Code Online (Sandbox Code Playgroud)
以下是我认为相关的文件的主要部分:
<modelVersion>4.0.0</modelVersion>
<groupId>com.xyz</groupId>
<artifactId>libraryparent</artifactId>
<version>1.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent library</name>
<description>A parent pom for all library modules</description>
<modules>
<module>../util</module>
<module>../streams</module>
</modules>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
<configuration>
<releaseProfiles>release</releaseProfiles>
<goals>deploy assembly:single</goals>
<!--
<autoVersionSubmodules>true</autoVersionSubmodules>
-->
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
<project .....>
<modelVersion>4.0.0</modelVersion>
<artifactId>util</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>com.xyz</groupId>
<artifactId>libraryparent</artifactId>
<relativePath>../libraryparent/pom.xml</relativePath>
<version>1.1-SNAPSHOT</version>
</parent>
</project> …Run Code Online (Sandbox Code Playgroud) 我得到一个NullPointerException,我无法理解为什么会发生这种情况.mainActivityWeakReference.get()似乎返回null.
所以我的猜测是重新创建Activity,并且一旦加载了类就将引用变量设置为null,并且只有在调用onCreate方法后才更新引用.但我不明白的是,我忙于在参考指向的活动中执行指令,但引用为空.
活动可以在短时间内共存,我该如何处理这种情况.对我来说,似乎简单的空检查不足以解决问题.也许我应该叫完();
public class MainActivity extends android.support.v7.app.AppCompatActivity {
private WeakReference<AppCompatActivity> mainActivityWeakReference = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
mainActivityWeakReference = new WeakReference<AppCompatActivity>(this);
}
public void handleAction(UserAction userAction) {
switch (userAction) {
case UPDATE_UI:
<< ERROR HERE
mainActivityWeakReference.get().getSupportFragmentManager().executePendingTransactions();
break;
}
}
Run Code Online (Sandbox Code Playgroud)
我的堆栈跟踪:
java.lang.NullPointerException: Attempt to read from field 'android.os.Handler android.support.v4.a.m.a' on a null object reference
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1476)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:490)
at za.co.entersekt.nedbank.MainActivity.handleAction(MainActivity.java:297)
Run Code Online (Sandbox Code Playgroud)
更多细节补充:
public abstract class FragmentManager {
....
public boolean execPendingActions() {
if (mExecutingActions) {
throw new IllegalStateException("Recursive …Run Code Online (Sandbox Code Playgroud) 我有一个XCUITest,它找不到特定的图像,但是在屏幕上完全可见。(模拟器和物理设备)
我怎样才能解决方法或使该UIImage的访问测试? 所有我想要验证是元素是否可见和可触摸屏幕上。
UIImage作为子视图添加到UITableView-放置在TableView的底部。
- (void)viewDidLoad {
[super viewDidLoad];
// portions of code left out here
_aView = [[UIImageView alloc] initWithFrame:CGRectZero];
[[self aView] setContentMode:UIViewContentModeScaleAspectFit];
[[self aView] setImage:[UIImage imageNamed:IMG_NAME]] ;
[[self tableView] addSubview:[self aView]];
Run Code Online (Sandbox Code Playgroud)
UIImageView稍后进行布局:
- (void) viewWillLayoutSubviews {
// portions of code left out here
[[self aView] setFrame:CGRectMake(0, MAX([self tableView].contentSize.height - 41 ,[self tableView].bounds.size.height - 41) , 180, 30)];
[[self aView] setCenter:CGPointMake([self tableView].center.x, [self aView].center.y)];
Run Code Online (Sandbox Code Playgroud)
然后在运行测试时:
let app = XCUIApplication()
//this works
let tapString = localizedString("skip")
let skipButton = app.buttons[tapString].firstMatch …Run Code Online (Sandbox Code Playgroud) 我知道这个问题似乎已经有人问过了,但这与 ASP.NET Core 而不是 ASP.NET 5 有关。
当用户关闭浏览器选项卡时,我试图让用户注销;我正在 MacOS 上使用 Chrome 和 Safari 对此进行测试。
目前,当我登录用户并关闭并重新打开浏览器选项卡时,用户保持登录状态。
当我登录用户在我设定的是AuthenticationProperties IsPersistent要false。然而,当浏览器选项卡关闭时,用户在 Chrome 和 Safari 上都保持登录状态。(浏览器没有关闭,只有选项卡)。
Task task = HttpContext.SignInAsync(principal,
new AuthenticationProperties
{
IsPersistent = false
});
await task;
Run Code Online (Sandbox Code Playgroud)
根据文档:persistent-cookies
“您可能希望 cookie 在浏览器会话中持续存在”
在上述情况下,我将 IsPersistent 设置为 false,并且我假设 cookie 不应在会话中存活。
据我了解,浏览器不会关闭会话,服务器会关闭,并且设置为以下 10 秒。
然而,通过如下测试,我无法让用户注销。
这可能无关紧要...... Starup.cs 有这个:
services.AddSession(options =>
{
// Set a short timeout for easy testing.
options.IdleTimeout = TimeSpan.FromSeconds(10);
options.Cookie.HttpOnly = …Run Code Online (Sandbox Code Playgroud) 我目前正在使用SHA256Managedin ASP.NET Core 3.1,为了更安全,我想使用Hash512.
后缀Managed表明一个是托管代码,而另一个不是。
有人可以解释一下使用非托管与托管时需要考虑的任何问题吗?非托管是否需要任何特殊部署,例如在 Docker 容器中/或操作系统要求。
private string Hash512(string str) {
var message = Encoding.Unicode.GetBytes(str);
var hash = SHA512.Create();
var hashValue = hash.ComputeHash(message);
return Encoding.Unicode.GetString(hashValue);
}
public string Hash256(string str)
{
var message = Encoding.Unicode.GetBytes(str);
var hash = new SHA256Managed();
var hashValue = hash.ComputeHash(message);
return Encoding.Unicode.GetString(hashValue);
}
Run Code Online (Sandbox Code Playgroud)