使用cURL的HTTP GET会导致SSL错误(HTTP GET using cURL is giving SSL error)
我写了一个REST服务器,它监听8000端口。我试图用cURL命令从同一台机器调用api -
curl -H "accept: application/json" https://localhost:8000/status -v
我收到以下错误
* About to connect() to localhost port 8000 (#0) * Trying ::1... * Connected to localhost (::1) port 8000 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * NSS error -12263 (SSL_ERROR_RX_RECORD_TOO_LONG) * SSL received a record that exceeded the maximum permissible length. * Closing connection 0 curl: (35) SSL received a record that exceeded the maximum permissible length.
我尝试使用-k选项绕过证书验证,但无济于事。 我在这里错过了什么? 如果需要更多信息,请发表评论。
编辑 :我的朋友建议尝试在cURL命令只有HTTP。 然后绕过SSL检查,它工作。 但https有什么问题? 我是否需要为localhost安装证书? 另外,为什么没有-k选项可用?
I have written a REST server which listens on port 8000. I am trying to invoke the api from the same machine using the cURL command -
curl -H "accept: application/json" https://localhost:8000/status -v
I am getting the following error
* About to connect() to localhost port 8000 (#0) * Trying ::1... * Connected to localhost (::1) port 8000 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * NSS error -12263 (SSL_ERROR_RX_RECORD_TOO_LONG) * SSL received a record that exceeded the maximum permissible length. * Closing connection 0 curl: (35) SSL received a record that exceeded the maximum permissible length.
I have tried bypassing the certificate verification using -k option but to no avail. What am I missing here? Please comment if any more info is required.
EDIT: My friend suggested to try with only http in the cURL command. Then it bypassed SSL check and it worked. But whats going wrong with https? Do I need to install certificate for localhost also? Also, why didn't -k option work?
原文:https://stackoverflow.com/questions/50581099
最满意答案
@Ben Morris,谢谢你的建议。
我认为这个解决方案可以帮助其他人,我已经检查了很多论坛,在插件中添加了设计,但是我没有得到正确的解决方案,所以我在
.java
(从CordovaPlugin
扩展)文件中实现了SurfaceView
Context activity = this.cordova.getActivity().getApplicationContext(); SurfaceView surfaceView = new SurfaceView(activity); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER); cordova.getActivity().addContentView(surfaceView, params);
@Ben Morris, Thank you for your suggestion.
I think this solution may help others, I have checked lot of forums to add the design in plugin but i didn't get proper solution so i have implemented
SurfaceView
in the.java
(Which extends fromCordovaPlugin
) file as bellowContext activity = this.cordova.getActivity().getApplicationContext(); SurfaceView surfaceView = new SurfaceView(activity); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER); cordova.getActivity().addContentView(surfaceView, params);
相关问答
更多-
删除一个cordova插件(Remove a cordova plugin)[2022-04-22]
尝试使用cordova plugin rm cordova-plugin-fcm --force other wise从Firebase下载google-services.json文件并将其放置在项目的根目录下,然后重试。 Try cordova plugin rm cordova-plugin-fcm --force other wise just download the google-services.json file from Firebase and place it in the root o ... -
要添加插件,请使用以下命令: cordova插件添加了PLUGIN_NAME 一旦添加了插件,为了调用插件代码,请在代码中注册deviceready事件并调用设备就绪事件侦听器中的插件代码。 同时确保在您的HTML中包含cordova.js文件,这会在开发时给出404错误,但是一旦您构建了Android或浏览器平台,它将包含在内,并且在执行期间它将可用。 看看这个SO发布了解更多信息。 您还可以查看此示例cordova应用程序 ,该应用程序使用本地通知插件作为插件调用的参考 To add plugin, u ...
-
检查你的其他插件。 如果你正在使用其他插件,其中一个犯规,它可能会破坏你的cordova.js,这反过来打破了cordova.plugins。 如果您从一个全新的项目开始,只需添加该特定插件,它就可以运行。 我试过了。 所以,我的赌注是其他一些代码正在犯规,并以某种方式打破了cordova.js。 尝试使用干净的项目,并运行您的代码。 另外,仔细看看你的javascript控制台,以防其他代码无意中破坏了cordova.js。 "Phonegap App" doesn't support external ...
-
@Ben Morris,谢谢你的建议。 我认为这个解决方案可以帮助其他人,我已经检查了很多论坛,在插件中添加了设计,但是我没有得到正确的解决方案,所以我在.java (从CordovaPlugin扩展)文件中实现了SurfaceView Context activity = this.cordova.getActivity().getApplicationContext(); SurfaceView surfaceView = new SurfaceView(activity); Frame ...
-
更新。 当我在等待回应时,我发现了一些开始做我需要的方法。 首先,我能够创建档案.csv。 $scope.criaCSV = function () { // Create Object var items = [ { name: "Item 1", color: "Green", size: "X-Large" }, { name: "Item 2", color: "Green", size: "X-Large" }, { name: " ...
-
无法使用Cordova插件(Unable to use Cordova Plugin)[2023-06-22]
您的问题就像您在上一段中提到的那样,您试图在浏览器中使用Cordova插件。 这是不可能的,因为这里没有适用于您的浏览器的phonegap抽象层。 所以我认为你有一些机会: 最可靠的是每次在您的设备上部署它并在那里进行测试。 是的,我知道,如果你尝试了很多不同的想法,这总是需要几秒钟,并不是最好的。 另一种选择可能是在ngCordovaMocks创建自己的$cordovaNetwork ngCordovaMocks 。 例: angular.module('ngCordovaMocks', []) ... -
问题是我需要()iCloudCV插件的javascript部分。 cordova导出的模块以插件的id为前缀,因此在“fr.pierrickrouxel.cordova.plugin.iCloudKV”插件中包含“iCloudCV”变量的完整代码是: var iCloudKV = require("fr.pierrickrouxel.cordova.plugin.iCloudKV.iCloudKV"); ......然后我可以正确地引用它。 The issue is that I needed to re ...
-
cordova插件java类中的本机通知android代码(native notification android code in cordova plugin java class)[2021-03-04]
我相信你需要提供至少一个小图标。 取消注释.setSmallIcon(1)并将.setSmallIcon(1)替换为可绘制的资源ID,以用作通知中的图标。 Finally i have done some changes in building the notification object and it worked for me. try{ Log.i(TAG, "In try block of notification"); Intent intent = new In ... -
Cordova安装插件(Cordova install plugin)[2022-03-01]
从这里安装最新的Nodejs: https ://nodejs.org/en/download/,安装最新的npm。 根据您正在使用的插件的repo ,该命令已被弃用。 请改用: cordova plugin add cordova-plugin-camera Install latest Nodejs from here: https://nodejs.org/en/download/ which installs latest npm. According to the repo of the plug ... -
Cordova sms插件(Cordova sms plugin)[2023-10-31]
对于Windows Universal,纯粹在Javascript中执行此操作是“最干净的”请参阅此https://github.com/cordova-sms/cordova-sms-plugin/issues/31 For Windows Universal, it is "cleanest" to do this purely in Javascript see this https://github.com/cordova-sms/cordova-sms-plugin/issues/31