@ -0,0 +1,113 @@ | |||||
package gq.yigit.mycity.tools; | |||||
import cz.msebera.android.httpclient.conn.scheme.HostNameResolver; | |||||
import cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory; | |||||
import javax.net.ssl.SSLContext; | |||||
import javax.net.ssl.TrustManager; | |||||
import javax.net.ssl.TrustManagerFactory; | |||||
import javax.net.ssl.X509TrustManager; | |||||
import java.io.IOException; | |||||
import java.net.Socket; | |||||
import java.security.*; | |||||
import java.security.cert.CertificateException; | |||||
import java.security.cert.X509Certificate; | |||||
import java.util.ArrayList; | |||||
import java.util.Arrays; | |||||
public class AdditionalKeyStoresSSLSocketFactory extends SSLSocketFactory { | |||||
protected SSLContext sslContext = SSLContext.getInstance("TLS"); | |||||
public AdditionalKeyStoresSSLSocketFactory(KeyStore keyStore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { | |||||
super(null, null, null, null, null, (HostNameResolver) null); | |||||
sslContext.init(null, new TrustManager[]{new AdditionalKeyStoresTrustManager(keyStore)}, null); | |||||
} | |||||
@Override | |||||
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException { | |||||
return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); | |||||
} | |||||
@Override | |||||
public Socket createSocket() throws IOException { | |||||
return sslContext.getSocketFactory().createSocket(); | |||||
} | |||||
/** | |||||
* Based on http://download.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#X509TrustManager | |||||
*/ | |||||
public static class AdditionalKeyStoresTrustManager implements X509TrustManager { | |||||
protected ArrayList<X509TrustManager> x509TrustManagers = new ArrayList<X509TrustManager>(); | |||||
protected AdditionalKeyStoresTrustManager(KeyStore... additionalkeyStores) { | |||||
final ArrayList<TrustManagerFactory> factories = new ArrayList<TrustManagerFactory>(); | |||||
try { | |||||
// The default Trustmanager with default keystore | |||||
final TrustManagerFactory original = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); | |||||
original.init((KeyStore) null); | |||||
factories.add(original); | |||||
for( KeyStore keyStore : additionalkeyStores ) { | |||||
final TrustManagerFactory additionalCerts = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); | |||||
additionalCerts.init(keyStore); | |||||
factories.add(additionalCerts); | |||||
} | |||||
} catch (Exception e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
/* | |||||
* Iterate over the returned trustmanagers, and hold on | |||||
* to any that are X509TrustManagers | |||||
*/ | |||||
for (TrustManagerFactory tmf : factories) | |||||
for( TrustManager tm : tmf.getTrustManagers() ) | |||||
if (tm instanceof X509TrustManager) | |||||
x509TrustManagers.add( (X509TrustManager)tm ); | |||||
if( x509TrustManagers.size()==0 ) | |||||
throw new RuntimeException("Couldn't find any X509TrustManagers"); | |||||
} | |||||
/* | |||||
* Delegate to the default trust manager. | |||||
*/ | |||||
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { | |||||
final X509TrustManager defaultX509TrustManager = x509TrustManagers.get(0); | |||||
defaultX509TrustManager.checkClientTrusted(chain, authType); | |||||
} | |||||
/* | |||||
* Loop over the trustmanagers until we find one that accepts our server | |||||
*/ | |||||
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { | |||||
for( X509TrustManager tm : x509TrustManagers ) { | |||||
try { | |||||
tm.checkServerTrusted(chain,authType); | |||||
return; | |||||
} catch( CertificateException e ) { | |||||
// ignore | |||||
} | |||||
} | |||||
throw new CertificateException(); | |||||
} | |||||
public X509Certificate[] getAcceptedIssuers() { | |||||
final ArrayList<X509Certificate> list = new ArrayList<X509Certificate>(); | |||||
for( X509TrustManager tm : x509TrustManagers ) | |||||
list.addAll(Arrays.asList(tm.getAcceptedIssuers())); | |||||
return list.toArray(new X509Certificate[list.size()]); | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,27 @@ | |||||
-----BEGIN RSA PRIVATE KEY----- | |||||
MIIEowIBAAKCAQEAoq3+G6YLhYXZK5Ay5SJPdC2EzJZeVR5HQ8Was/KZblMdEsxB | |||||
xGj6AYQcIR18AjmA9f6eH2iYzbNqSIjgKAOpoayL+rctpIocgqsQfM/gSndmYh5y | |||||
W0WVK3on/dZmv/aDVBLzEYdQiOEFtTSR9NNBhJSdcz3sACJ6GmFnNgsczgC4FgsR | |||||
wTiHbXpSw8oSWjIgVVHj6vSwARgJR4inJEyynNaMouS8K4NTLfLnXTgdTSmCWinm | |||||
Ac1ViHKOenTwe7ws+wmJvX8dZU95WC/8IX7b+wakstdnPsZUmDDLZ4tzuttDur9Z | |||||
o6aA7zKv4nipF1apF1Q6dm8wctbCVADMGbF49wIDAQABAoIBAFkJO6OsTHAG4uaJ | |||||
5KEuFyhx5VYIEpcpnD2GgHZul/Ue/jGUo4Y5ImQEB1VEiuO4z1FTyv1LxR4ITWpn | |||||
p6+e2Y/IHVDaQtvkT1hhAgQdzhdTpDCdk19LBSqnkA3I87Gq3RP9zxVP5w8TgYk8 | |||||
vYmuuhQzNr2lLW6hcAzSNKgKivhf4vtQiFgxTOis0pKoW6DjqPo94OQwB9AJVBJW | |||||
Hsk9v2teJI5hjM6mIamlMtsMci0e24cNcBRv1bbI5/qgHkkbQkT4Gm/E91y86tyN | |||||
KtoWDdEhiX6mNYaQ5KK+mFK9v7vA/hq445D112Xv0nuTs+Ov/uYitlkxFgVjLxMs | |||||
DgD6VkkCgYEAziLldENXljvnVMBIwfe75JCzD6bQLS0vSl/kbY40X6PIGjT2aiJd | |||||
+OJWUNVfMX+5Ldk82IVkTuOZmn/MGuz7qMIqTheWqGLVIEgF4tAZMsyq6oXY9rUY | |||||
qHjoxyW8VLkPLooUuTK0k7B+JBi/M7ds5125iLIBPp8lGJ0ng1GrG+sCgYEAyggE | |||||
7DOQEjeUEXOhEm0D+hQ8UKhtI1N0d7Usf+B5T/XP62gHHtcLRYctwoPFGY3lqLqd | |||||
gkrYBVG0A2COEEtRJZNf6zihGX40Uluq3P5X84MxvD6CqsVXZ64fCPcTf4SoVYpC | |||||
I0WpsJTR2RDCLTrxn+/n7a8NAdxOlv27vEt3UCUCgYEAvFcH/NU2po5vC3FwSME3 | |||||
zFslL6zDUjORnMvGow6l7ahwQPmZF1n1MFxkbxC1HD3NjQWKYW5nOukbRB11+DgE | |||||
q6lUC+vjfFBo2EjWD+kAzPhRRVwr4yWNtQhb7vEchPBc3bHNw3R/pt1AM2zk7bSu | |||||
7SomRa4WEwhHVZjpLEOnKicCgYB8UPjue0AQ5aA4KOWZV/mVfbQrkaguj6DgNFyg | |||||
h3k+iayaV1XiVUL7UpYG1lyHP/hsngBj9zf79e2GEnj4b9AMBiaEsED5Vd5OO1fl | |||||
SqDGGBmXkwOGn44MH2m7c4XM9s06bawK1kf3f2utXRGPEXEzEEWvzQJ8/ZpicNl/ | |||||
oRRW/QKBgGNtRTr4+Hv2lqx4iApAbITPeBY+Y/ZA02w5iYUgWV6cpOiBKwivbFp5 | |||||
KcLwPpeRq8Cp5eOs97n01mxxTSYaxok2BHvJDF3sJy2XjvP4on8209FNmn+0FKSy | |||||
apfPSsWHlunD6MXrK13mofjwRS2CqDhZRomynIeeQ+kvnt74TBt3 | |||||
-----END RSA PRIVATE KEY----- |
@ -0,0 +1,22 @@ | |||||
-----BEGIN CERTIFICATE----- | |||||
MIIDuTCCAqECFB4w/WXumGEKLcUlhWqZCNDVXtzgMA0GCSqGSIb3DQEBCwUAMIGY | |||||
MQswCQYDVQQGEwJUUjEPMA0GA1UECAwGQW5rYXJhMQ0wCwYDVQQHDARjaXR5MRAw | |||||
DgYDVQQKDAdUZWRSb2JvMRwwGgYDVQQLDBNSZXNlYXJjLURldmVsb3BtZW50MQ4w | |||||
DAYDVQQDDAVZaWdpdDEpMCcGCSqGSIb3DQEJARYaeWlnaXRjb2xha29nbHVAaG90 | |||||
bWFpbC5jb20wHhcNMTkwMzIzMjIxNzI4WhcNMjAwMzIyMjIxNzI4WjCBmDELMAkG | |||||
A1UEBhMCVFIxDzANBgNVBAgMBkFua2FyYTENMAsGA1UEBwwEY2l0eTEQMA4GA1UE | |||||
CgwHVGVkUm9ibzEcMBoGA1UECwwTUmVzZWFyYy1EZXZlbG9wbWVudDEOMAwGA1UE | |||||
AwwFWWlnaXQxKTAnBgkqhkiG9w0BCQEWGnlpZ2l0Y29sYWtvZ2x1QGhvdG1haWwu | |||||
Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoq3+G6YLhYXZK5Ay | |||||
5SJPdC2EzJZeVR5HQ8Was/KZblMdEsxBxGj6AYQcIR18AjmA9f6eH2iYzbNqSIjg | |||||
KAOpoayL+rctpIocgqsQfM/gSndmYh5yW0WVK3on/dZmv/aDVBLzEYdQiOEFtTSR | |||||
9NNBhJSdcz3sACJ6GmFnNgsczgC4FgsRwTiHbXpSw8oSWjIgVVHj6vSwARgJR4in | |||||
JEyynNaMouS8K4NTLfLnXTgdTSmCWinmAc1ViHKOenTwe7ws+wmJvX8dZU95WC/8 | |||||
IX7b+wakstdnPsZUmDDLZ4tzuttDur9Zo6aA7zKv4nipF1apF1Q6dm8wctbCVADM | |||||
GbF49wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQB5qiPEzBlnxIIUmIVbSpQmhUl9 | |||||
PVNtgbtndsnqwZG9lZIO3zFUTQNUi/oD+ifA769GvybyRTaMqGOgC8sKythgetHB | |||||
UQcFdnq7rLTetVJX+N2LkxeL4yFmLBYceTaKkjHQEDyTflNJDcNMlOn4cekam058 | |||||
qLc4+dnoIryTuy+4RLQXtBGOtXqA8kxtQ3OTDnXtBpzojR1RIVMPxO4ES4tU7c3D | |||||
Pt3h5UZaKGr2I4PdMZ2f4KBieXKZqcbXcCcp/XuRqxcQBk6hM2U9IesZZGH2Q4yd | |||||
VQBFWd0u0Ghre2M8sFURjq6tfqdAkAV+XMTVjHwwtkCi061h8++56y47YAy3 | |||||
-----END CERTIFICATE----- |
@ -0,0 +1,18 @@ | |||||
-----BEGIN CERTIFICATE REQUEST----- | |||||
MIIC3jCCAcYCAQAwgZgxCzAJBgNVBAYTAlRSMQ8wDQYDVQQIDAZBbmthcmExDTAL | |||||
BgNVBAcMBGNpdHkxEDAOBgNVBAoMB1RlZFJvYm8xHDAaBgNVBAsME1Jlc2VhcmMt | |||||
RGV2ZWxvcG1lbnQxDjAMBgNVBAMMBVlpZ2l0MSkwJwYJKoZIhvcNAQkBFhp5aWdp | |||||
dGNvbGFrb2dsdUBob3RtYWlsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC | |||||
AQoCggEBAKKt/humC4WF2SuQMuUiT3QthMyWXlUeR0PFmrPymW5THRLMQcRo+gGE | |||||
HCEdfAI5gPX+nh9omM2zakiI4CgDqaGsi/q3LaSKHIKrEHzP4Ep3ZmIecltFlSt6 | |||||
J/3WZr/2g1QS8xGHUIjhBbU0kfTTQYSUnXM97AAiehphZzYLHM4AuBYLEcE4h216 | |||||
UsPKEloyIFVR4+r0sAEYCUeIpyRMspzWjKLkvCuDUy3y5104HU0pglop5gHNVYhy | |||||
jnp08Hu8LPsJib1/HWVPeVgv/CF+2/sGpLLXZz7GVJgwy2eLc7rbQ7q/WaOmgO8y | |||||
r+J4qRdWqRdUOnZvMHLWwlQAzBmxePcCAwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IB | |||||
AQBa8CzIRznPZBo2nNxRscBArKOcGoJw4GK5hjAeqnlXEgkUkPoDu7xyVi6W6zAY | |||||
XkApJ0gIHm3dPe7M/PWZV95yndD3VzzgyCD25/J2ITlDHEklBse6//giO0I2CdoF | |||||
xZVCGUsFdBloqL+z67dJB2BSzAa1m7jjSP9451/Mxi58rkJ/jB+UKF/gA5YCsBw0 | |||||
SPfLMojdWXFwfWw21reG7z4JGxe6w8CxqpLtqYvI4etO8Jm18j6OSd/KtIcOpSqw | |||||
pkAJcIUXyPG4HzWR4UGlm+mzWtfxcn40BiS2gfO+bvVOR12Wp6KBoc581mzKDEnS | |||||
ZkoE888GmvDy5Fxi7WHkq8eS | |||||
-----END CERTIFICATE REQUEST----- |
@ -0,0 +1,30 @@ | |||||
-----BEGIN RSA PRIVATE KEY----- | |||||
Proc-Type: 4,ENCRYPTED | |||||
DEK-Info: DES-EDE3-CBC,7F4B0128759DB527 | |||||
kPMg2ciG0ja/s8+wmk41ypIjI+F6lQdRfKxs4byXIeRiy+tPKtreD9AK53sDKv3L | |||||
pmWQ/qAoCZZLXmgZj5Wzk7yi1h5z5OdU7kBBNMUasReGtK003Zztfvk0rO5Taa0L | |||||
wmsHao53a/efTWj344Fq7YAqWbusYRnD2GY74GLVKvWSI6pjOoFG0oQii0YAdYYJ | |||||
l97eBmMOI939XFIhT+HernP2E3mNjNw+MPSEyQldsirYMvpOrX9LbDwvRwvFCtOO | |||||
XI+815bdTGwP5TUd4auQY1xrpjQ9AEQRlRFU63BLY34tfSXudwHcEBUDZXineZdw | |||||
XwhK+Zuoz52esjOr9yEMGgtYECO83jdIHeTt0L7bu6EEofl9oeIGYZzOjXUQ//rp | |||||
1yo/mXM8cQ+F3zma0nC1wA0UGWs6oBwEgNAiwJShuC7dWfjPwPS8V2oCDnU8CUez | |||||
C4lp83242BkA9Ux8kVLg12CBj49rR4fvYucXK+Vd1O56kDHV2GvRhQjxDZjbkSwk | |||||
5XHe8JK8pgapwsHLVBo8ZfF7NldVcTqcZ7y8f315YY31BpLQn9OfWEtgJrISdL1e | |||||
ICxhhocdldH1mfGaqG45S82Yz1Q7k2iFwAjbqbV2krzwW4YDGzuVQCVB4qtIq3Fo | |||||
L1Vuyt4SHevIs4Pda2pchIsa2hB/3Pdnjd+GoTkj5ALdMo6aU4ZjqaTo0ezk7CgC | |||||
GbIaFP9xl5oprXYDxxLNWa7LsMZ8IMtDaAnI0Q/YhzimZEnnN4/RMGbSmbd6WrlF | |||||
n/Q5H46QLqtmjXKpI/LUdTXljsoXHfB5PLkQ6VPc9s0pr+qmWJG9v2X1dg4TcnMV | |||||
zKNaknGhtQnsSaID0x4ocwL+o/ro2DQ9mzps5vU8VS2NOAXy8QJKG+2hO02sm7G9 | |||||
2GB/li3CortE8hn/zcOIsFR7mdMvFIQWwJKyDV3pcPlgVO0RdANRzebVbusEPNF8 | |||||
JNSEgWVypqwfHVTeHzvSMUgENb5bsQwtM9tlq1CvhHrdFCf28YWueaYJVoQnfhIz | |||||
JvgodDmPUOilb8sW3kZQ8pHOHNDMEV3uG3VVuXLF0KQY1XUSKloEFz/AXK3kYjiN | |||||
xOSe6vYtJCINJkzk/ZdlhlVhuTml4HPqXeb8V/p1Dm2zVfebs6S3ATIhtPLMnLoq | |||||
9yAwiBaQ79XsI7MBPAllh4Y/FY9b3B/VNmBRvRfHRv23jXxjjBJBMf7XTX11d+cY | |||||
9LX/IVKNCx6EZ70IPlYogUr3w7Wml/QvpXT7WKDCnJy/9qejANYLfON1t4y/5ZWs | |||||
jo0yWFUycXVEjUyANYzkgUDN1AOaRI6zTrWcR58cV3+pxjnQBQBtZBxJzYkUVJDG | |||||
gO/KWpSAoeRR1OdVbUlilzM+PquJPsUyhsiAOFq7jkblYEasF5vTA9OFx4Fka99b | |||||
iHc+FLHhpH1Glpg82PZEfO7A2Ef+P6mufm0jm1Q9tl3qGf3OiOgXQLqcFDXb0ggV | |||||
V5clnJ0HVqtPulUDQzzEW9F2NFuhSE0XyY5BhpXQ0GWAwxlVAGqRl4k/krk8cnK8 | |||||
O3+TfXoVnch1qS5X3gM/XKEu+UZnUtYtvDykFOCPeXQKCOKfra+fbw== | |||||
-----END RSA PRIVATE KEY----- |
@ -0,0 +1,22 @@ | |||||
-----BEGIN CERTIFICATE----- | |||||
MIIDuTCCAqECFB4w/WXumGEKLcUlhWqZCNDVXtzgMA0GCSqGSIb3DQEBCwUAMIGY | |||||
MQswCQYDVQQGEwJUUjEPMA0GA1UECAwGQW5rYXJhMQ0wCwYDVQQHDARjaXR5MRAw | |||||
DgYDVQQKDAdUZWRSb2JvMRwwGgYDVQQLDBNSZXNlYXJjLURldmVsb3BtZW50MQ4w | |||||
DAYDVQQDDAVZaWdpdDEpMCcGCSqGSIb3DQEJARYaeWlnaXRjb2x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ghre2M8sFURjq6tfqdAkAV+XMTVjHwwtkCi061h8++56y47YAy3 | |||||
-----END CERTIFICATE----- |
@ -0,0 +1,28 @@ | |||||
import os | |||||
import json | |||||
import hashlib | |||||
from flask import Flask, request | |||||
from flask_restful import Resource, Api, abort | |||||
app = Flask(__name__) | |||||
api = Api(app) | |||||
with open(os.path.join(app.root_path, 'userdata.json'), 'r') as f: | |||||
data = json.load(f) | |||||
class Login( Resource ): | |||||
def post(self): | |||||
req = request.args | |||||
print(req) | |||||
if __name__ == '__main__': | |||||
api.add_resource(Login, '/login', '/login/') | |||||
app.run(host='0.0.0.0', port=5000) |
@ -0,0 +1,3 @@ | |||||
{ | |||||
} |