I use OpenSSL to establish a secured connection with my local HTTPS server. The server is really simple as I basically used the Boost Asio example but only improved a bit.
The solution works on Win7 64b using OpenSSL-Win32 and the certificates which comes with installer downloaded here.
I have ported the solution on Android. The Android OpenSSL port is from here.
Everything works fine until the use_tmp_dh_file method is called:
_context.use_tmp_dh_file("/sdcard/Download/PEM/dh512.pem");
It always ends up with the Fatal signal 11 (SIGSEGV) at 0x00000014 (code=1) error.
I use certificates server.pem and dh512.pem from the /apps folder of Android OpenSSL port.
Does anybody have an idea what is wrong?
EDIT:
Using a dh file is not mandatory, it works without it, but I am only a one step further because now it fails when starting handshake:
boost::system::error_code error;
socket.handshake(boost::asio::ssl::stream_base::server, error);
Where socket is instance of:
typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> sslSocket;
It ends up with the same error as above. It seems to be an Android OpenSSL-Boost ASIO issue.
The answer on this particular question is short and simple, but it was quite hard to find it. The native library implementing my HTTPS server was interfering with the other native library using OpenSSL as well.
Related
I was trying to open cache.properties.lock file present in .gradle
and suddenly Android Studio got crashed with Incompatible magic error popup.
How to fix this issue? No idea.
I also struggled with this issue a lot while we were sending JAVA classes in an enterprise - this is primarily caused when class (compiled) classes that are sent over mails as attachments and the proxy servers tampers with the content.
This can happen when using a proxy server, and especially when the CLASS files were sent as .TXT extensions to avoid PROXY/FIREWALL blockings to secured enterprise environments.
I tried to look for some answers for me here, but I just fail to find anything that solves my problem.
In project I am working on we are going to change our domain. Change is bit tricky - we have to also change connection from HTTP to HTTPS. I've received .crt key (let's say, example.tech.crt - will change all of company name to "example"). After few hours of constant failures I decided to write here.
First of all, I tried using this tutorial http://ogrelab.ikratko.com/using-android-volley-with-self-signed-certificate/ - and it didn't work (I don't even mean that I had to use deprecated Apache libs because of API23). In case this is needed, this is how I created BKS file:
keytool -importcert -v -trustcacerts -file "example.tech.crt" -alias example_tech
-keystore "example_tech.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider
-providerpath "bcprov-jdk16-146.jar" -storetype BKS
Then, I tried this approach Does Android Volley support SSL? - the one from best answer (with ignoring domain name check). I still tried to use BKS file - I've got some exceptions about casting errors, so I changed line:
CertificateFactory cf = CertificateFactory.getInstance("X.509");
to
CertificateFactory cf = CertificateFactory.getInstance("X.509", "BC");
as suggested somewhere - error still persisted. I tried to use .crt file instead of BKS - I still fail.
Every single time I get same error:
javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException:
SSL handshake aborted: ssl=0x650f83a0: Failure in SSL library, usually a protocol error
error:14077102:SSL routines:SSL23_GET_SERVER_HELLO:unsupported protocol
(external/openssl/ssl/s23_clnt.c:714 0x5fda0d74:0x00000000)
I tried to do pretty much same requests using Postman and they work on same address without any problem, so this is not server problem. I tried to use various domains - example.tech, www.example.tech, example.tech:80 and so on (always with https of course).
Below is example curl-like request (of course censored):
curl request: curl -X "POST"
-D "grant_type=password&password=[passwordHere]&username=[emailHere]&"
-H 'Authorization: Basic [tokenHere]
"https://example.tech/oauth/token"
I fail to see what's wrong with my code and I'd be really happy to see what I am doing wrong in here. If there's any more code needed, feel free to ask for it (but 99% of it is like in second link, only with really small changes).
Consider this topic as example of poor comunication. After hours of trying to make this work we made to work:
we are NOT using selfsigned certificates, so adding key to application is terrible idea (since they change each 3 months)
unsupported protocol exception came from older Android APIs (<20 or <21), which are supported in this application. From I do understand (considering my poor knowledge about SSL connections) our site uses TLS, but older Android systems (pre-Lollipop I guess) have this turned off by default. Proper way of fixing this was creating custom TLSSocketFactory and using it in HurlStack used to initialize RequestQueue. After that exception disappeared.
I am trying to implement DTLS in my Android client using openssl/bio.h library.
The same does not cause any errors in iOS, while in Android..the DTLS handshake failure gives the following error
ssl3_write_pending:BIO_NOT_SET
I do not understand that error, has anyone tried this before or faced this issue? Did not find much help through google
I got the DTLS Handshake working after changing my DTLS code ,which was earlier using OpenSSL TO BoringSSL.I changed all the functions signature from that of OpenSSL to BoringSSL.
So a few days ago I got my hands on an Arduino Mega ADK board, and the last couple of nights I have been setting up my development environment, getting to grips with the tools etc. The tools and libraries all work fine, for example I can get a program written in the Processing IDE to compile and run on an Asus Eee Pad Transformer TF101 running Android 4.03. But when I get it to try to compile and run one of the pre-written examples, it gives me a compiler error:
Android SDK Tools Revision 20
Installed at C:\NVPACK\android-sdk-windows
Project Type: Application
Project Target: Android 2.3.3
API level: 10
Library dependencies:
No Libraries
API<=15: Adding annotations.jar to the classpath.
Merging AndroidManifest files into one.
Manifest merger disabled. Using project manifest only.
No AIDL files to compile.
No RenderScript files to compile.
Generating resource IDs...
Generating BuildConfig class.
BUILD FAILED
C:\NVPACK\android-sdk-windows\tools\ant\build.xml:680: The following error occurred while executing this line:
C:\NVPACK\android-sdk-windows\tools\ant\build.xml:693: Compile failed; see the compiler error output for details.
Total time: 7 seconds
And that's all the console seems to output as well, which is rather frustrating! As far as I'm aware all of my SDK versions, tools and plugins are all up to date. I've tried this using a Linux partition I have on my hard drive and it produces the same error message, although it mentions a problem with the package com.Android.future.UsbAccessory. Given what I've seen, it seems that the problem is with the tools, either my directory structure doesn't match up to what the correct setup is, or something else is wrong :S. If anyone has had similar problems, some help would be smashing! (For the record, my setup was done using the instructions on the Arduino website, although I already had the Android SDK tools installed).
Will Scott-Jackson
It sounds like your haven't added in the support library to your project and/or you haven't downloaded it into your Android SDK.
The ADK1 demokit app targets API Level 10 (Android 2.3.3); That means you need to use the support libraries in your project and that's why the compiler is complaining about level 10 library dependencies not being available. The support libraries are a separate download in the SDK Manager, so you might not have them in your development environment.
In Android API Level 12 and higher, the USB Accessory protocol was added to the framework API, so there are two different ways to use the accessory protocol. So, you don't have to use the support libraries if you are targeting Honeycomb and higher versions, but you'll have to update the demokit app code to make this work.
Hope this helps.
So I've double checked my setup and started working on a project I had in mind, it seems to import the libraries appropriately. So far so good, but when I input:
ArduinoAdkUsb arduino;
void setup() {
arduino = new ArduinoAdkUsb(this);
//Other UI initialisation etc.
}
I get this error:
##name## ##version## by ##author##
FATAL EXCEPTION: Animation Thread
java.lang.NoClassDefFoundError: com.android.future.usb.UsbManager
at cc.arduino.ADKCommunication.<init>(Unknown Source)
at cc.arduino.ArduinoAdkUsb.<init>(Unknown Source)
at
processing.android.test.sketch_120730a.
sketch_120730a.setup(sketch_120730a.java:48)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:856)
After the app has been built and installed onto the Android tablet I am using. Any thoughts how I can over come this? From what I can tell, this has no problem finding com.android.future.usb.manager to compile and install the program, but once it tries to run it can find it.
Based on this tutorial from http://stream.tellart.com/controlling-arduino-with-android/
In the examples RGB_Arduino the name, version and author variables are set at the top of the sketch.
Try adding in this section of code at the top of your arduino sketch just underneath the library imports
// accessory descriptor. It's how Arduino identifies itself to Android
char applicationName[] = "Mega_ADK"; // the app on your phone
char accessoryName[] = "Mega_ADK"; // your Arduino board
char companyName[] = "Freeware";
// make up anything you want for these
char versionNumber[] = "1.0";
char serialNumber[] = "1";
char url[] = "http://labs.arduino.cc/adk/"; // the URL of your app online
//initialize the accessory:
AndroidAccessory usb(companyName, applicationName,
accessoryName,versionNumber,url,serialNumber);
I'm trying to make a project using the arduino ADK board http://arduino.cc/en/Main/ArduinoBoardADK and a Sony Ericsson Xperia Play running android 2.3.4. For starters all I want to do is blink a led from my android device, using the nice tutorial found here http://allaboutee.com/2011/12/31/arduino-adk-board-blink-an-led-with-your-phone-code-and-explanation/ .I managed to compile the android app but I'm having big difficulties on the arduino sketch, I can't resolve the imports and it won't compile on Windows7. I understand there are some arduino IDE version issues. I tried compiling both on 0022, 0023 and on 1.0. The furthest I could go with the code I was getting these compile errors after editing the AndroidAccessory.h:
D:\arduino-0023\libraries\AndroidAccessory/AndroidAccessory.h:37: error: 'EP_RECORD' does not name a type
D:\arduino-0023\libraries\AndroidAccessory/AndroidAccessory.h:50: error: 'EP_RECORD' has not been declared
D:\arduino-0023\libraries\AndroidAccessory/AndroidAccessory.h:50: error: 'EP_RECORD' has not been declared
D:\arduino-0023\libraries\AndroidAccessory/AndroidAccessory.h:64: error: 'USB_NAK_LIMIT' was not declared in this scope
I think I read the whole documentation and I can't find a solution to my problem. Setting this up is such a pain... I really need to make this work. Thank you in advance! :)
---------------------------------------------------------------------------------------------------------------------------
EDIT1: The solution which worked for me was to compile the sketch on Linux (Ubuntu)
---------------------------------------------------------------------------------------------------------------------------
EDIT2: Once again using the newest USB library from arduino website the code DOESN'T compile. I tried compiling on IDE v22 and v1.0.2 running both Windows 8 and Ubuntu 12.10 with the following errrors:
E:\Development\arduino-1.0.2\libraries\UsbHost/AndroidAccessory.h: In function 'void setup()':
E:\Development\arduino-1.0.2\libraries\UsbHost/AndroidAccessory.h:68: error: 'void AndroidAccessory::powerOn()' is private
sketch_jan10a:16: error: within this context
E:\Development\arduino-1.0.2\libraries\UsbHost/AndroidAccessory.h: In function 'void loop()':
E:\Development\arduino-1.0.2\libraries\UsbHost/AndroidAccessory.h:66: error: 'int AndroidAccessory::read(void*, int, unsigned int)' is private
sketch_jan10a:23: error: within this context
The library was written and tested in:
Arduino Alpha 0022
Have you tried adding this to ArduinoAccessory.h?
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
Also I would recommend reading through this as well:
http://developer.android.com/guide/topics/usb/adk.html#installing
It specifically mentions you need the CapSense library as well for the Android shield on an Arduino:
http://www.arduino.cc/playground/Main/CapSense
It also mentions that you need to install avr-libc as well:
sudo apt-get install avr-libc
MAC OS X:
fink install avr-libc avr-gcc avr-binutils avrdude
EP_RECORD is defined as part of the USB Host Shield 1.0. However, it is being removed in USB Host Shield 2.0 library.
See the announcement here: http://www.circuitsathome.com/mcu/usb-host-shield-library-version-2-0-released
So the error messages you have with EP_RECORD will surface again if you ever upgrade to 2.0. Also check out the adk.h and adk.cpp from version 2.0 on GitHub. The updated DemoKit 2.0 example no longer use the AndroidAccessory.h/.cpp.
Sounds to me like you're just missing the USB_Host_Shield/Usb.h header, which defines those constants.
Place this code where other defines are in Usb.h
#define USB_NAK_LIMIT 32000 //NAK limit for a transfer. 0 means NAKs are not counted
Place this just after SETUP_PKT's typedef in Usb.h
/* Endpoint information structure */
/* bToggle of endpoint 0 initialized to 0xff */
/* during enumeration bToggle is set to 00 */
typedef struct {
byte epAddr; //copy from endpoint descriptor. Bit 7 indicates direction ( ignored for control endpoints )
byte Attr; // Endpoint transfer type.
unsigned int MaxPktSize; // Maximum packet size.
byte Interval; // Polling interval in frames.
byte sndToggle; //last toggle value, bitmask for HCTL toggle bits
byte rcvToggle; //last toggle value, bitmask for HCTL toggle bits
/* not sure if both are necessary */
} EP_RECORD;
I think if we really know what this EP_Record epRecord[8]; is all about that might help. EP_Record has not been declared in this file. Therefore, it does not have a type. When I gave USB_NAK_LIMIT a type of int that error went away. I have no idea what type to give to EP_Record? The only thing I can think of is that it might be an array epRecord[8]; looks like an array.
While the Android Developer's site is useful it does lack in many ways. One would be some online help for developers. This seems the be the only source for answers to questions and most of them do not really solve the problems.
This sounds kind of like a issue I had a while ago.
(so I used microbridge not the ADK with a USBDroid) I had to
go into 3 libraries, The error message pointed me to them
//(Note:Which were copied into the the general arduino sketch folder not the arduino normal libraries location) That may be your issue?)
I then replace wiring.h with Arduino.h in each.(Note Make a backup of all to save some stuffing around if this is not your issue) Copy then into a folder named the same but with a number before the name that way when you restart the arduino software you will get a error ignore this and compile.
The result was working USBdroid as seen at
http://www.youtube.com/watch?v=h7aa_6PNdRI
Still a Work in progress but made me happy. I still have a few buggs to work out.
Cheers,
Al
Install ArduinoADK BETA 001 which is the latest ADK available till date.
Unzip it and in the arduino folder you will find libraries and libraries-V2.
If you copy USB host in libraries you will get androidaccessory.h read private error
Copy USB host from libraries V 2 you should be able to compile successfully. I was.