-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
2,297 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>com.subgraph.vega.sslprobe</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
7 changes: 7 additions & 0 deletions
7
platform/com.subgraph.vega.sslprobe/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
3 changes: 3 additions & 0 deletions
3
platform/com.subgraph.vega.sslprobe/.settings/org.eclipse.pde.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
eclipse.preferences.version=1 | ||
pluginProject.extensions=false | ||
resolve.requirebundle=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Sslprobe | ||
Bundle-SymbolicName: com.subgraph.vega.sslprobe | ||
Bundle-Version: 1.0.0.qualifier | ||
Bundle-Activator: com.subgraph.vega.sslprobe.Activator | ||
Bundle-Vendor: SUBGRAPH | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8, | ||
JavaSE-1.7 | ||
Import-Package: com.google.common.collect, | ||
com.subgraph.vega.api.model.alerts, | ||
org.apache.http;version="4.2.3", | ||
org.osgi.framework;version="1.3.0" | ||
Export-Package: com.subgraph.vega.sslprobe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
. |
104 changes: 104 additions & 0 deletions
104
...m.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/CertificateAnalyzer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.subgraph.vega.internal.sslprobe; | ||
|
||
import java.security.InvalidKeyException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.NoSuchProviderException; | ||
import java.security.PublicKey; | ||
import java.security.SignatureException; | ||
import java.security.interfaces.RSAPublicKey; | ||
|
||
import javax.security.cert.CertificateException; | ||
import javax.security.cert.X509Certificate; | ||
|
||
public class CertificateAnalyzer { | ||
|
||
private X509Certificate certificate; | ||
private boolean error = false; | ||
|
||
CertificateAnalyzer () { | ||
|
||
} | ||
|
||
public void addCert(X509Certificate certificate) { | ||
this.certificate = certificate; | ||
} | ||
|
||
|
||
public boolean selfSigned() { | ||
|
||
PublicKey k = certificate.getPublicKey(); | ||
try { | ||
certificate.verify(k); | ||
} catch (InvalidKeyException e) { | ||
System.out.println("Invalid key, not self signed"); | ||
return false; | ||
} catch (NoSuchAlgorithmException e) { | ||
return false; | ||
} catch (NoSuchProviderException e) { | ||
return false; | ||
} catch (SignatureException e) { | ||
return false; | ||
} catch (CertificateException e) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
public boolean isSignedSHA1() { | ||
return certificate.getSigAlgName().startsWith("SHA1"); | ||
} | ||
|
||
public boolean isSignedMD5() { | ||
return certificate.getSigAlgName().startsWith("MD5"); | ||
} | ||
|
||
public boolean isRSA() { | ||
return "RSA".equals(certificate.getPublicKey().getAlgorithm()); | ||
} | ||
|
||
public int getRSAModulusBitLength() { | ||
if (this.isRSA()) { | ||
RSAPublicKey r = (RSAPublicKey) certificate.getPublicKey(); | ||
return r.getModulus().bitLength(); | ||
} | ||
else return -1; | ||
} | ||
|
||
public void setError(boolean error) { | ||
this.error = error; | ||
} | ||
|
||
public X509Certificate getCertificate() { | ||
return this.certificate; | ||
} | ||
|
||
public boolean isError() { | ||
return this.error; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return (certificate == null) ? 0 : certificate.getSerialNumber().hashCode(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} else if (obj == null || getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
|
||
final CertificateAnalyzer other = (CertificateAnalyzer) obj; | ||
|
||
if (certificate == null) { | ||
return other.certificate == null; | ||
} | ||
|
||
if(certificate.getSerialNumber() == null) { | ||
return other.certificate.getSerialNumber() == null; | ||
} | ||
|
||
return certificate.getSerialNumber().equals(other.certificate.getSerialNumber()); | ||
} | ||
} |
Oops, something went wrong.