Security 无法在AuthenticationFetcher micronaut中获取客户端证书

Security 无法在AuthenticationFetcher micronaut中获取客户端证书,security,authorization,micronaut,Security,Authorization,Micronaut,我正在尝试在AuthenticationFetcher实现中获取客户端证书,以实现自定义授权 @Singleton public class SslAuthenticationFetcher implements AuthenticationFetcher { private static final Logger LOGGER = LoggerFactory.getLogger(SslAuthenticationFetcher.class); private static fi

我正在尝试在
AuthenticationFetcher
实现中获取客户端证书,以实现自定义授权

@Singleton
public class SslAuthenticationFetcher implements AuthenticationFetcher {
    private static final Logger LOGGER = LoggerFactory.getLogger(SslAuthenticationFetcher.class);
    private static final String AUTHENTICATION = "AUTHENTICATION";

    private final SessionStore<? extends Session> sessionStore;
    private final X509CertificateParser x509CertificateParser;

    @Inject
    public SslAuthenticationFetcher(X509CertificateParser x509CertificateParser,
                                    SessionStore<? extends Session> sessionStore) {
        this.x509CertificateParser = x509CertificateParser;
        this.sessionStore = sessionStore;
    }

    @Override
    public Publisher<Authentication> fetchAuthentication(HttpRequest<?> request) {
        
        // Code to check if user-session already exist
        
        UserDetails userDetails = getAuthentication(request);
        session.put(AUTHENTICATION, userDetails);    

        return Flowable.just(userDetails);
    }

    @NotNull
    private UserDetails getAuthentication(HttpRequest<?> request) {
        Optional<Certificate> certificate = request.getCertificate(); // This always returns empty
        if (!certificate.isPresent()) {
            throw new AuthenticationException("No certificate chain found");
        }
        
        // Code to parse the certificate to create UserDetails
    }
}
下面是我在
application test.yml
文件中的客户端ssl配置

micronaut:
  http:
    client:
      ssl:
        enabled: true
        client-authentication: need
        key-store:
          path: <key-store file path>.p12
          password: <key-store file password>
          type: PKCS12
        trust-store:
          path: <trust-store file path>.jks
          password: <trust-store file password>
          type: JKS
        protocol: TLS
micronaut:
http:
客户:
ssl:
已启用:true
客户端身份验证:需要
密钥存储:
路径:.p12
密码:
类型:PKCS12
信任存储:
路径:.jks
密码:
类型:JKS
协议:TLS
问题是,在
SslAuthenticationFetcher
中,当我尝试从
request
获取证书时,它总是返回一个
可选的.empty
。这里可能存在什么问题

  • Micronaut版本:2.0.0
  • Java版本:1.8

这个问题解决了吗?
micronaut:
  http:
    client:
      ssl:
        enabled: true
        client-authentication: need
        key-store:
          path: <key-store file path>.p12
          password: <key-store file password>
          type: PKCS12
        trust-store:
          path: <trust-store file path>.jks
          password: <trust-store file password>
          type: JKS
        protocol: TLS