Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SSLCertificateApprovalCallback.approve() #1016

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.mozilla.jss.ssl;

import java.security.cert.X509Certificate;
import java.util.Enumeration;
import java.util.Vector;

Expand Down Expand Up @@ -43,8 +44,7 @@ public interface SSLCertificateApprovalCallback {
* <b>false</b> terminate the connection (Expect an IOException
* on the outstanding read()/write() on the socket)
*/
public boolean approve(org.mozilla.jss.crypto.X509Certificate cert,
ValidityStatus status);
public boolean approve(X509Certificate cert, ValidityStatus status);

/**
* This class holds details about the errors for each cert in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package org.mozilla.jss.ssl;

import java.security.cert.X509Certificate;
import java.util.Enumeration;

import org.mozilla.jss.CryptoManager;
Expand All @@ -19,7 +20,7 @@ public class TestCertApprovalCallback

@Override
public boolean approve(
org.mozilla.jss.crypto.X509Certificate servercert,
X509Certificate servercert,
SSLCertificateApprovalCallback.ValidityStatus status) {

SSLCertificateApprovalCallback.ValidityItem item;
Expand Down Expand Up @@ -60,7 +61,9 @@ public boolean approve(
System.out.println("importing certificate.");
try {
CryptoManager cm = CryptoManager.getInstance();
PK11Cert newcert = (PK11Cert) cm.importCertToPerm(servercert, "testnick");
PK11Cert newcert = (PK11Cert) cm.importCertToPerm(
(org.mozilla.jss.crypto.X509Certificate) servercert,
"testnick");
newcert.setSSLTrust(PK11Cert.TRUSTED_PEER | PK11Cert.VALID_PEER);
} catch (Exception e) {
System.out.println("thrown exception: " + e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package org.mozilla.jss.tests;

import java.security.cert.X509Certificate;
import java.util.Enumeration;

import org.mozilla.jss.CryptoManager;
Expand All @@ -26,7 +27,7 @@ public class TestCertificateApprovalCallback

@Override
public boolean approve(
org.mozilla.jss.crypto.X509Certificate servercert,
X509Certificate servercert,
SSLCertificateApprovalCallback.ValidityStatus status) {

SSLCertificateApprovalCallback.ValidityItem item;
Expand Down Expand Up @@ -68,7 +69,9 @@ public boolean approve(

try {
CryptoManager cm = CryptoManager.getInstance();
PK11Cert newcert = (PK11Cert) cm.importCertToPerm(servercert, "testnick");
PK11Cert newcert = (PK11Cert) cm.importCertToPerm(
(org.mozilla.jss.crypto.X509Certificate) servercert,
"testnick");
newcert.setSSLTrust(PK11Cert.TRUSTED_PEER | PK11Cert.VALID_PEER);
} catch (Exception e) {
System.out.println("thrown exception: "+e);
Expand Down
5 changes: 5 additions & 0 deletions docs/changes/v5.6.0/API-Changes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ The `org.mozilla.jss.ssl.SSLSocket` has been modified to extend `javax.net.ssl.S
== JSSSocket Changes ==

The `org.mozilla.jss.ssl.javax.JSSSocket` has been modified to extend `org.mozilla.jss.ssl.SSLSocket`.

== SSLCertificateApprovalCallback Changes ==

The `approve()` method in `org.mozilla.jss.ssl.SSLCertificateApprovalCallback` has been modified
to accept `java.security.cert.X509Certificate` instead of `org.mozilla.jss.crypto.X509Certificate`.
2 changes: 1 addition & 1 deletion native/src/main/native/org/mozilla/jss/util/java_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ PR_BEGIN_EXTERN_C
* SSLCertificateApprovalCallback
*/
#define SSLCERT_APP_CB_APPROVE_NAME "approve"
#define SSLCERT_APP_CB_APPROVE_SIG "(Lorg/mozilla/jss/crypto/X509Certificate;Lorg/mozilla/jss/ssl/SSLCertificateApprovalCallback$ValidityStatus;)Z"
#define SSLCERT_APP_CB_APPROVE_SIG "(Ljava/security/cert/X509Certificate;Lorg/mozilla/jss/ssl/SSLCertificateApprovalCallback$ValidityStatus;)Z"

/*
* SSLSecurityStatus
Expand Down
Loading