nativescript-community / https

Secure HTTP client with SSL pinning for Nativescript - iOS/Android
https://nativescript-community.github.io/https/
Other
50 stars 42 forks source link

Is nativescript-https compatible with webpack? #21

Closed dgma7 closed 6 years ago

dgma7 commented 6 years ago

Hi, I'm trying to webpack my app, but I'm getting this error from this plugin:

 nativescript-https > enableSSLPinning error Error: java.security.cert.CertificateException: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: inStream is empty
JS:     com.android.org.conscrypt.OpenSSLX509CertificateFactory.engineGenerateCertificate(OpenSSLX509CertificateFactory.java:274)
JS:     java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:196)
JS:     com.tns.Runtime.runModule(Native Method)
JS:     com.tns.Runtime.runModule(Runtime.java:530)
JS:     com.tns.Runtime.run(Runtime.java:522)
JS:     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
JS:     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1018)
JS:     android.app.ActivityThread.handleBindApplication(ActivityThread.java:4959)
JS:     android.app.ActivityThread.-wrap1(ActivityThread.java)
JS:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1549)
JS:     android.os.Handler.dispatchMessage(Handler.java:111)
JS:     android.os.Looper.loop(Looper.java:207)
JS:     android.app.ActivityThread.main(ActivityThread.java:5728)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
JS: Caused by: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: inStream is empty
JS:     com.android.org.conscrypt.OpenSSLX509CertificateFactory$Parser.generateItem(OpenSSLX509CertificateFactory.java:115)
JS:     com.android.org.conscrypt.OpenSSLX509CertificateFactory.engineGenerateCertificate(OpenSSLX509CertificateFactory.java:272)
JS:     java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:196)
JS:     com.tns.Runtime.runModule(Native Method)
JS:     com.tns.Runtime.runModule(Runtime.java:530)
JS:     com.tns.Runtime.run(Runtime.java:522)
JS:     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
JS:     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1018)
JS:     android.app.ActivityThread.handleBindApplication(ActivityThread.java:4959)
JS:     android.app.ActivityThread.-wrap1(ActivityThread.java)
JS:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1549)
JS:     android.os.Handler.dispatchMessage(Handler.java:111)
JS:     android.os.Looper.loop(Looper.java:207)
JS:     android.app.ActivityThread.main(ActivityThread.java:5728)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
JS: Caused by: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: inStream is empty
JS:     com.android.org.conscrypt.OpenSSLX509CertificateFactory$Parser.generateItem(OpenSSLX509CertificateFactory.java:82)
JS:     com.android.org.conscrypt.OpenSSLX509CertificateFactory.engineGenerateCertificate(OpenSSLX509CertificateFactory.java:272)
JS:     java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:196)
JS:     com.tns.Runtime.runModule(Native Method)
JS:     com.tns.Runtime.runModule(Runtime.java:530)
JS:     com.tns.Runtime.run(Runtime.java:522)
JS:     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
JS:     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1018)
JS:     android.app.ActivityThread.handleBindApplication(ActivityThread.java:4959)
JS:     android.app.ActivityThread.-wrap1(ActivityThread.java)
JS:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1549)
JS:     android.os.Handler.dispatchMessage(Handler.java:111)
JS:     android.os.Looper.loop(Looper.java:207)
JS:     android.app.ActivityThread.main(ActivityThread.java:5728)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
JS:     com.android.internal.os
JS: .ZygoteInit.main(ZygoteInit.java:749)

this plugin is compatible with webpack or there's is something more to config to make it work?

Guatom commented 6 years ago

Hey @dgmaar! Are you still having the problem? I just made this work, maybe I can help if you still need it. Greetings from _travelDevs.

roblav96 commented 6 years ago

@dgmaar Apologies but I have not used webpack with Nativescript so I do not have any input on this matter. @sis0k0 is the queen 👑 of webpack =]

But from the looks of it your error is caused by an invalid certificate path inStream is empty.

Guatom commented 6 years ago

Dude! I just wanted to know whether he still needed that. He has to add the certificate file to the list of files copied by Webpack. Something like this:

new CopyWebpackPlugin([
            { from: mainSheet },
            { from: "css/**" },
            { from: "fonts/**" },
            { from: "**/*.jpg" },
            { from: "**/*.png" },
            { from: "**/*.xml" },
            { from: "**/*.cer" }, // This one!
        ], { ignore: ["App_Resources/**"] }),
dgma7 commented 6 years ago

@Guatom Thanks for reply, yeah I'm still with the problem... I'll try your solution... thank you very much

dgma7 commented 6 years ago

Yep that was the problem, Thank you very much @Guatom

Guatom commented 6 years ago

Glad to help, @dgmaar.

roblav96 commented 6 years ago

@Guatom My apologies, I thought you came off as if you were soliciting yourself. Sorry :X