有谁知道Volley是否支持Android中的SSl?有没有办法通过Volley支持SSL?
使用此网络库:
由于目前的状态是开发,我想使用自签名SSL证书
图书馆论坛有一些讨论:
https://github.com/koush/ion/issues/3
Ion ion = Ion.getDefault(c);
ion.configure().createSSLContext("TLS");
ion.getHttpClient().getSSLSocketMiddleware().setSSLContext(sslContext);
ion.getHttpClient().getSSLSocketMiddleware().setTrustManagers(trustManagers);
Run Code Online (Sandbox Code Playgroud)
经过一些研究,我抓住了crt并获得了sslContext和trustmanager,问题是,它仍然返回异常
javax.net.ssl.SSLException
Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Run Code Online (Sandbox Code Playgroud)
这是我的尝试:
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
InputStream caInput = getResources().openRawResource(R.raw.load);
Certificate ca;
try {
ca = cf.generateCertificate(caInput);
//System.out.println("ca=" + ((X509Certificate) ca).getSubjectDN());
} finally {
caInput.close();
}
String keyStoreType = KeyStore.getDefaultType();
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
keyStore.load(null, null);
keyStore.setCertificateEntry("ca", ca);
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
tmf.init(keyStore);
ssl_context = SSLContext.getInstance("TLS");
ssl_context.init(null, tmf.getTrustManagers(), null);
} catch (Exception …Run Code Online (Sandbox Code Playgroud) 当我放入RecyclerView内部NestedScrollView然后onBindViewHolder调用所有行,比如说我有大小为30的列表然后一次onBindViewHolder调用所有30行,即使没有滚动
RecyclerView list;
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
list.setLayoutManager(layoutManager);
layoutManager.setAutoMeasureEnabled(true);
list.setNestedScrollingEnabled(false);
list.addItemDecoration(new VerticalSpaceItemDecoration(5));
list.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)
我的xml是
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_views"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/info"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textAlignment="center"
android:visibility="visible"
/>
Run Code Online (Sandbox Code Playgroud)
但如果我删除NestedScrollView它正常工作.
android android-recyclerview nestedscrollview android-nestedscrollview
我想获取从我的应用登录的用户的所有谷歌私人连接.我启用了Google People和Google Plus API.我设置了凭证API密钥,客户端ID和客户端密钥.我正在尝试获取用户连接的URL是
https://people.googleapis.com/v1/people/me/connections?fields=connections&key=api_key&access_token=access_token
Run Code Online (Sandbox Code Playgroud)
另外,我正在使用图书馆passport-google-oauth来获取用户access_token.以上网址中是否有任何我遗漏的内容.
我的谷歌验证码是
// send to google to do the authentication
// profile gets us their basic information including their name
// email gets their emails
app.get('/auth/google', passport.authenticate('google', {
scope: ['profile', 'email','https://www.googleapis.com/auth/contacts.readonly', 'https://www.googleapis.com/auth/contacts']
}));
// the callback after google has authenticated the user
app.get('/auth/google/callback',
passport.authenticate('google', {
successRedirect: '/profile',
failureRedirect: '/'
}));
Run Code Online (Sandbox Code Playgroud) google-api google-api-nodejs-client passport-google-oauth google-people
我已经实现AutoCompleteTextView如下:
MainActivity.java
...
public static String[] myData=new String[]{"Africa (AF)","America (AFM)","Apple (AMP)"};
text=(AutoCompleteTextView)v.findViewById(R.id.first_state);
ArrayAdapter adapter = new ArrayAdapter(getActivity(),R.layout.autocompletetextview_row,R.id.textViewItem,myData);
text.setAdapter(adapter);
text.setThreshold(1);
text.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
selected_station = (String)parent.getItemAtPosition(position);
//TODO Do something with the selected text
}
});
Run Code Online (Sandbox Code Playgroud)
布局AutoCompleteTextView:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:padding="10dp" >
<TextView
android:id="@+id/textViewItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Item name here..."
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
当我输入类似"af .."时,它显示非洲(AF)选择但不是美国(AFM).
数据只是一个示例数据.这不是我AutoCompleteTextView只用于3件物品.
编辑:当我删除括号时,它正常工作.但我需要保留括号以供进一步使用.
我有以下错误Hostname domain.com not verified:不是"javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated"我以前能够连接到不同的主机,在这个主机我遇到问题,如何解决它
javax.net.ssl.SSLPeerUnverifiedException: Hostname domain.com not verified:
certificate: sha1//WQM9QbrKs6DCFa9qN/EIw1ywBw=
DN: CN=*.ipage.com,OU=Domain Control Validated - RapidSSL(R),OU=See www.rapidssl.com/resources/cps (c)14,OU=GT29505539
subjectAltNames: [*.ipage.com, ipage.com]
at com.squareup.okhttp.Connection.connectTls(Connection.java:244)
at com.squareup.okhttp.Connection.connectSocket(Connection.java:199)
at com.squareup.okhttp.Connection.connect(Connection.java:172)
at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
at com.squareup.okhttp.Call.getResponse(Call.java:267)
Run Code Online (Sandbox Code Playgroud)
这是我的代码
try {
JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("name", name);
jsonObject.accumulate("password", pass);
jsonObject.accumulate("email", emails);
json = jsonObject.toString();
Log.e("MYAPP", "getjson");
} catch (JSONException e) {
Log.e("MYAPP", "unexpected JSON exception", e);
}
try{
RequestBody formBody = new …Run Code Online (Sandbox Code Playgroud) 我正在尝试让我的应用通过https与我的服务器通信.由于我不想付费以获得由受信任的CA签署的服务器证书,因此解决方案是使用自签名证书.
所以,我创建了我的caconfig.cnf如下:
[ ca ]
default_ca = CA_default # The default ca section
[ CA_default ]
dir = ./demoCA # top dir
database = $dir/index.txt # index file.
new_certs_dir = $dir/newcerts # new certs dir
certificate = $dir/cacert.pem # The CA cert
serial = $dir/serial # serial no file
private_key = $dir/private/cakey.pem # CA private key
RANDFILE = $dir/private/.rand # random number file
default_days = 365 # how long to certify for
default_crl_days = 30 # how long before next …Run Code Online (Sandbox Code Playgroud) 实际上,本周,我有与以下相同的问题
在我的手机(摩托罗拉、Android 4.1.2)中,我禁用了所有 DigiCert CA(内部Settings - Security - Trusted credentials - System)。
我的代码如下:
public class CertPinActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cert_pin);
try {
CertificatePinner certificatePinner = new CertificatePinner.Builder()
.add("github.com", "sha256/WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=")
.build();
OkHttpClient client = new OkHttpClient.Builder()
.sslSocketFactory(getSSLSocketFactory())
.certificatePinner(certificatePinner)
.build();
Request request = new Request.Builder()
.url("https://github.com/square/okhttp/wiki/HTTPS")
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("onFailure","-------------------------------------------------");
e.printStackTrace();
}
@Override
public void onResponse(Call call, Response response) throws …Run Code Online (Sandbox Code Playgroud) 我在Android上写了一些Rest客户端,我遇到了一个问题 - 我不知道如何制作HEAD和OPTIONS请求.
OkHttp3中的GET/POST/PUT/DELETE/PATCH请求没有问题,基本上它们看起来像:
request = new Request.Builder()
.url(url)
.headers(headerBuilder.build())
.post(bodyBuilder.build())
.build();
Run Code Online (Sandbox Code Playgroud)
并且OkHttp3不提供其他方法,如head()或option().
那么如何使用OkHttp3创建HEAD和OPTIONS请求?
我在应用程序中遇到了一个问题,我认为它可能与Volley从缓存中提取数据有关.
也就是说,应用程序与API紧密绑定,因此每次更改都会发送到API,然后使用Volley库从API中检索.因此,用户将打开一个弹出窗口,选择一些组来查看其项目,然后选择一些值来标记它的最爱.弹出窗口将关闭,片段将重新加载新数据.
当用户再次打开弹出窗口时,选择相同的组来加载其数据,之前的项目将不会显示为收藏夹.但是当用户再次触摸同一组以重新加载其数据时,该项目将显示为收藏夹.
我已经逐步调试了代码,但没有发现任何错误.所以我得出结论,Volley可能会从其缓存中提取数据,同时在我第二次点击该组时启动新的API请求.
我想测试它是否是缓存问题或者我必须更深入地调试.
有没有办法告诉Volley不要使用缓存的请求数据,而是启动对API的新请求?有点像don't use cached data, but make a new request.
注意:我不想删除完整的缓存.我只想告诉Volley什么时候发起一个全新的API请求.
android ×9
https ×3
okhttp ×3
ssl ×3
okhttp3 ×2
self-signed ×2
android-ion ×1
caching ×1
google-api ×1
java ×1
node.js ×1