Skip to content

Commit

Permalink
SSLProbe
Browse files Browse the repository at this point in the history
  • Loading branch information
dma committed Oct 15, 2014
1 parent c300ab4 commit d0fe35b
Show file tree
Hide file tree
Showing 23 changed files with 2,297 additions and 0 deletions.
7 changes: 7 additions & 0 deletions platform/com.subgraph.vega.sslprobe/.classpath
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>
28 changes: 28 additions & 0 deletions platform/com.subgraph.vega.sslprobe/.project
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>
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
14 changes: 14 additions & 0 deletions platform/com.subgraph.vega.sslprobe/META-INF/MANIFEST.MF
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
4 changes: 4 additions & 0 deletions platform/com.subgraph.vega.sslprobe/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
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());
}
}
Loading

0 comments on commit d0fe35b

Please sign in to comment.