Skip to content

Commit 0b959eb

Browse files
committed
Return X500Principal from getPeerPrincipal() and getLocalPrincipal()
1 parent 276eff7 commit 0b959eb

5 files changed

Lines changed: 8 additions & 14 deletions

File tree

src/java/com/wolfssl/provider/jsse/WolfSSLEngine.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@ protected synchronized void cacheRequestedServerNamesFromNetData() {
321321
List<SNIServerName> names;
322322
WolfSSLImplementSSLSession session;
323323

324-
if (this.engineHelper == null ||
325-
this.engineHelper.getUseClientMode()) {
324+
if (this.engineHelper == null || this.engineHelper.getUseClientMode()) {
326325
return;
327326
}
328327

src/java/com/wolfssl/provider/jsse/WolfSSLImplementSSLSession.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -673,12 +673,11 @@ public Certificate[] getLocalCertificates() {
673673
public synchronized Principal getPeerPrincipal()
674674
throws SSLPeerUnverifiedException {
675675

676-
/* Use standard Java X509Certificate.getSubjectDN()
677-
* for X500Name equals() compatibility */
676+
/* Return X500Principal for proper equals() symmetry */
678677
Certificate[] certs = getPeerCertificates();
679678
if (certs != null && certs.length > 0 &&
680679
certs[0] instanceof X509Certificate) {
681-
return ((X509Certificate) certs[0]).getSubjectDN();
680+
return ((X509Certificate) certs[0]).getSubjectX500Principal();
682681
}
683682
throw new SSLPeerUnverifiedException("No peer certificate");
684683
}
@@ -699,7 +698,7 @@ public Principal getLocalPrincipal() {
699698
if (certs.length > 0){
700699
/* When chain of certificates exceeds one,
701700
* the user certifcate is the first */
702-
localPrincipal = certs[0].getSubjectDN();
701+
localPrincipal = certs[0].getSubjectX500Principal();
703702
}
704703

705704
/* free native resources earlier than garbage collection if
@@ -1137,8 +1136,7 @@ public synchronized List<SNIServerName> getRequestedServerNames()
11371136
byte[] sniRequestArr = null;
11381137

11391138
if (this.ssl == null) {
1140-
if (this.sniServerNames != null &&
1141-
!this.sniServerNames.isEmpty()) {
1139+
if (this.sniServerNames != null && !this.sniServerNames.isEmpty()) {
11421140
return Collections.unmodifiableList(
11431141
new ArrayList<SNIServerName>(this.sniServerNames));
11441142
}

src/java/com/wolfssl/provider/jsse/WolfSSLInternalVerifyCb.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ else if (sock != null) {
310310
}
311311
} catch (Exception e) {
312312
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
313-
() -> "Hostname verification error: " +
314-
e.getMessage());
313+
() -> "Hostname verification error: " + e.getMessage());
315314
this.verifyException = e;
316315
return 0;
317316
} finally {

src/test/com/wolfssl/provider/jsse/test/WolfSSLEngineTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,8 +2843,7 @@ public void testBufferUnderflowPartialRecord()
28432843
partialBuf.flip();
28442844

28452845
ByteBuffer outBuf = ByteBuffer.allocate(
2846-
server.getSession()
2847-
.getApplicationBufferSize());
2846+
server.getSession().getApplicationBufferSize());
28482847

28492848
/* Unwrap partial record: BUFFER_UNDERFLOW expected */
28502849
result = server.unwrap(partialBuf, outBuf);

src/test/com/wolfssl/provider/jsse/test/WolfSSLTestFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,7 @@ public int CloseConnection(SSLEngine server, SSLEngine client,
870870
if (!s.toString().equals("NEED_WRAP") ||
871871
!result.getStatus().name().equals("CLOSED") ) {
872872
throw new SSLException(
873-
"Bad status: HS=" + s +
874-
" status=" + result.getStatus());
873+
"Bad status: HS=" + s + " status=" + result.getStatus());
875874
}
876875

877876
/* server wraps its own close_notify */

0 commit comments

Comments
 (0)