authentication - ReSTLet with Simple - 尽管 needClientAuthentication 设置为 true,它接受任何没有客户端证书的连接

标签 authentication ssl restlet

我正在使用 ReSTLet 2.0.8 和简单设置:

    component = new Component();
    component.getClients().add(Protocol.FILE);
    Server httpsServer = component.getServers().add(Protocol.HTTPS, 444);

    Series<Parameter> parameters = httpsServer.getContext().getParameters();

    File pwd = new File(".");
    String path = pwd.getCanonicalPath();
    String keystorePath = path + "/keystore/keypair.jks";

    parameters.add("SSLContextFactory", "org.restlet.ext.ssl.PkixSslContextFactory");
    parameters.add("keystorePath", keystorePath);
    parameters.add("keystorePassword", "xxx");
    parameters.add("keyPassword", "xxx");
    parameters.add("keystoreType", "JKS");
    parameters.add("threadMaxIdleTimeMs", "60000"); //default idle time
    parameters.add("needClientAuthentication", "true");

    // Guard the restlet with BASIC authentication (encrypted under SSL).
    ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "xxx");

    //new pagerreceiver
    Restlet resty = new PagerReceiverApplication();

    LoginChecker loginVerifier = new LoginChecker();
    guard.setVerifier(loginVerifier);
    guard.setNext(resty);
    component.getDefaultHost().attachDefault(guard);

    overrideStatus statusService = new overrideStatus();
    component.setStatusService(statusService);

    component.start();

SSL 工作正常,但它接受任何连接,无论它们是否有客户端证书!这里到底发生了什么,我错过了什么吗?

最佳答案

一段时间,直到this patch in the Simple Framework (rev. 1785) , Simple 总是使用“想要客户端身份验证”,没有任何方式配置它(“需要”或“无”)。

因此,Simple ReSTLet 连接器的needClientAuthentication 参数从未得到支持,因为 ReSTLet 连接器本身无法更改此行为。

据我所知,Simple rev. 1785 只删除任何形式的客户端身份验证(没有“需要”或“想要”)。我不确定 ReSTLet 2.0.8 是否使用此补丁之前或之后的 Simple 版本,但迄今为止,似乎没有任何东西提供此支持。

这里有关于此主题的简单邮件列表的讨论:

有一些解决方法:

  • 为您的 ReSTLet 应用程序使用与 Simple 不同的连接器。其他的应该支持needClientAuthentication
  • 继续使用wantClientAuthentication(前提是是打过补丁的Simple版本),检查是否确实有证书,否则禁止请求。 (我认为 IIS 就是这样做的,即使它“需要”证书也是如此。)

作为旁注,查看您的代码,我不确定您为什么要坚持要求客户端同时提供客户端证书和 HTTP 基本身份验证凭据。基本授权在客户端证书之上似乎有点矫枉过正。

关于authentication - ReSTLet with Simple - 尽管 needClientAuthentication 设置为 true,它接受任何没有客户端证书的连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6481656/

相关文章:

android - 在 django 服务器中使用 android 应用程序进行身份验证

php - 我可以从数据库中获取我的盐,然后在同一个查询中检查密码吗?

java - 我应该使用哪个 Java 库通过 Facebook、Gmail、本地身份验证等进行身份验证?

ssl - 明文捕获 HTTPS 流量?

java - 在 ReSTLet 请求上设置 GET 参数的推荐方法是什么?

ios - Storyboard实用程序

.htaccess - 使用 https 将 www URL 重定向到非 www

ssl - 在 DigitalOcean 中使用 cloudflare 的 Universal SSL

reSTLet - 在 ReSTLet 中获取应用程序的路径(上下文根)

java - ReSTLet 添加参数到 webservice 调用