如何在polarssl中读取客户端证书?

时间:2016-02-12 12:55:04

标签: ssl tls1.2 mbed polarssl

如何使用mbedtls(polarssl) 从服务器端读取客户端证书? 我有一个使用mbedtls(polarssl)编码的服务器。我想阅读客户端证书并从该证书中获取一些信息。任何人都可以知道将使用什么功能来读取客户端证书?

1 个答案:

答案 0 :(得分:0)

我认为您可以使用mbedtls_x509_crt_info返回有关证书的信息字符串。

当客户端连接然后打印出信息时,您可以 public static void popupWindow(final Context context,String title ,String desc,final CrudStateCallback back){ final Dialog dialog = new Dialog(context, R.style.ShowPopup); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.R.color.transparent)); dialog.setContentView(R.layout.sticky_layout); colourTitleBar(context, dialog); String sansproEL = "fonts/source_sans_pro_extraLight.ttf"; String sansproL = "fonts/source_sans_pro_light.ttf"; Typeface sansproL_TF = Typeface.createFromAsset(context.getAssets(), sansproL); Typeface sansproEL_TF = Typeface.createFromAsset(context.getAssets(), sansproEL); ((TextView)dialog.findViewById(R.id.popup_text)).setTypeface(sansproL_TF); ((TextView)dialog.findViewById(R.id.popup_text2)).setTypeface(sansproEL_TF); TextView text = (TextView) dialog.findViewById(R.id.popup_text); TextView text2 = (TextView) dialog.findViewById(R.id.popup_text2); RelativeLayout container = (RelativeLayout) dialog.findViewById(R.id.all_container); View.OnClickListener dismissList = new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if(back!= null) back.onResponse(""); } }; text.setText(title); text2.setText(desc); container.setOnClickListener(dismissList); PSLocationCenter.getInstance().instabug.setDialog(dialog); dialog.show(); Handler han = new Handler(); han.postDelayed(new Runnable() { @Override public void run() { try{ dialog.dismiss(); }catch (Exception e){ Log.i("","error in popup window"); } if(back!= null) back.onResponse(""); } }, 3000); } public static void colourTitleBar(Context context, Dialog dialog) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); dialog.getWindow().setStatusBarColor(context.getResources().getColor(android.R.color.transparent)); } }

<style name="ShowPopup">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowAnimationStyle">@style/ShowPopupAnimation</item>
    <item name="android:windowCloseOnTouchOutside">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowTitleSize">0dp</item>

我没有对此进行测试,只是查看了示例。