Skip to content

Commit

Permalink
Merge pull request #57 from arduino/rp2040
Browse files Browse the repository at this point in the history
Fixed all warnings / added support for Arduino Nano RP2040 Connect
  • Loading branch information
cmaglie authored May 7, 2021
2 parents 09070b8 + 245dfd7 commit b8aeea3
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 120 deletions.
Binary file not shown.
Binary file added firmwares/NINA/1.4.5/NINA_W102-Uno_WiFi_Rev2.bin
Binary file not shown.
Binary file added firmwares/NINA/1.4.5/NINA_W102.bin
Binary file not shown.
2 changes: 0 additions & 2 deletions src/cc/arduino/plugins/wifi101/SerialPortListModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
package cc.arduino.plugins.wifi101;

import java.util.List;
import java.util.Map;
import java.util.HashMap;

import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
Expand Down
80 changes: 39 additions & 41 deletions src/cc/arduino/plugins/wifi101/UpdaterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,18 @@
*/
package cc.arduino.plugins.wifi101;

import java.io.File;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import static java.util.Arrays.asList;

import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;

import cc.arduino.packages.BoardPort;
import cc.arduino.plugins.wifi101.flashers.Flasher;
import cc.arduino.plugins.wifi101.flashers.java.WINCFlasher;
import cc.arduino.plugins.wifi101.flashers.java.NinaFlasher;
import cc.arduino.plugins.wifi101.flashers.java.WINCFlasher;
import processing.app.Base;

@SuppressWarnings("serial")
Expand All @@ -55,7 +48,7 @@ public class UpdaterImpl extends UpdaterJFrame {

public ArrayList<String> compatibleBoard;

public static ArrayList<Flasher> fwAvailable = new ArrayList<Flasher>();
public static ArrayList<Flasher> fwAvailable = new ArrayList<>();

public UpdaterImpl() throws Exception {
super();
Expand All @@ -64,33 +57,36 @@ public UpdaterImpl() throws Exception {
});
Base.setIcon(this);

fwAvailable.add(new WINCFlasher("WINC1501 Model B", "19.6.1", "firmwares/WINC1500/19.6.1/m2m_aio_3a0.bin", true, 1000000, new ArrayList<String>(asList("Arduino/Genuino MKR1000"))));
fwAvailable.add(new WINCFlasher("WINC1501 Model B", "19.5.4", "firmwares/WINC1500/19.5.4/m2m_aio_3a0.bin", true, 1000000, new ArrayList<String>(asList("Arduino/Genuino MKR1000"))));
fwAvailable.add(new WINCFlasher("WINC1501 Model B", "19.5.2", "firmwares/WINC1500/19.5.2/m2m_aio_3a0.bin", true, 1000000, new ArrayList<String>(asList("Arduino/Genuino MKR1000"))));
fwAvailable.add(new WINCFlasher("WINC1501 Model B", "19.4.4", "firmwares/WINC1500/19.4.4/m2m_aio_3a0.bin", true, 1000000, new ArrayList<String>(asList("Arduino/Genuino MKR1000"))));
fwAvailable.add(new WINCFlasher("WINC1501 Model A", "19.4.4", "firmwares/WINC1500/19.4.4/m2m_aio_2b0.bin", true, 115200, new ArrayList<String>(asList("Arduino WiFi 101 Shield"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.4", "firmwares/NINA/1.4.4/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.4", "firmwares/NINA/1.4.4/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, new ArrayList<String>(asList("Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.3", "firmwares/NINA/1.4.3/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.3", "firmwares/NINA/1.4.3/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, new ArrayList<String>(asList("Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.2", "firmwares/NINA/1.4.2/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.2", "firmwares/NINA/1.4.2/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, new ArrayList<String>(asList("Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.1", "firmwares/NINA/1.4.1/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.1", "firmwares/NINA/1.4.1/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, new ArrayList<String>(asList("Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.0", "firmwares/NINA/1.4.0/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.0", "firmwares/NINA/1.4.0/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, new ArrayList<String>(asList("Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.3.0", "firmwares/NINA/1.3.0/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.3.0", "firmwares/NINA/1.3.0/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, new ArrayList<String>(asList("Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.4", "firmwares/NINA/1.2.4/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.4", "firmwares/NINA/1.2.4/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, new ArrayList<String>(asList("Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.3", "firmwares/NINA/1.2.3/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.3", "firmwares/NINA/1.2.3/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, new ArrayList<String>(asList("Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.2", "firmwares/NINA/1.2.2/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.2", "firmwares/NINA/1.2.2/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, new ArrayList<String>(asList("Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.1", "firmwares/NINA/1.2.1/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.1", "firmwares/NINA/1.2.1/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, new ArrayList<String>(asList("Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.1.0", "firmwares/NINA/1.1.0/NINA_W102.bin", true, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010", "Arduino MKR Vidor 4000", "Arduino Uno WiFi Rev2"))));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.0.0", "firmwares/NINA/1.0.0/NINA_W102.bin", false, 1000000, new ArrayList<String>(asList("Arduino MKR WiFi 1010", "Arduino MKR Vidor 4000", "Arduino Uno WiFi Rev2"))));
fwAvailable.add(new WINCFlasher("WINC1501 Model B", "19.6.1", "firmwares/WINC1500/19.6.1/m2m_aio_3a0.bin", true, 1000000, asList("Arduino/Genuino MKR1000")));
fwAvailable.add(new WINCFlasher("WINC1501 Model B", "19.5.4", "firmwares/WINC1500/19.5.4/m2m_aio_3a0.bin", true, 1000000, asList("Arduino/Genuino MKR1000")));
fwAvailable.add(new WINCFlasher("WINC1501 Model B", "19.5.2", "firmwares/WINC1500/19.5.2/m2m_aio_3a0.bin", true, 1000000, asList("Arduino/Genuino MKR1000")));
fwAvailable.add(new WINCFlasher("WINC1501 Model B", "19.4.4", "firmwares/WINC1500/19.4.4/m2m_aio_3a0.bin", true, 1000000, asList("Arduino/Genuino MKR1000")));
fwAvailable.add(new WINCFlasher("WINC1501 Model A", "19.4.4", "firmwares/WINC1500/19.4.4/m2m_aio_2b0.bin", true, 115200, asList("Arduino WiFi 101 Shield")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.5", "firmwares/NINA/1.4.5/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.5", "firmwares/NINA/1.4.5/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.5", "firmwares/NINA/1.4.5/NINA_W102-Nano_RP2040_Connect.bin", true, 1000000, asList("Arduino Nano RP2040 Connect")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.4", "firmwares/NINA/1.4.4/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.4", "firmwares/NINA/1.4.4/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.3", "firmwares/NINA/1.4.3/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.3", "firmwares/NINA/1.4.3/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.2", "firmwares/NINA/1.4.2/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.2", "firmwares/NINA/1.4.2/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.1", "firmwares/NINA/1.4.1/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.1", "firmwares/NINA/1.4.1/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.0", "firmwares/NINA/1.4.0/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.4.0", "firmwares/NINA/1.4.0/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.3.0", "firmwares/NINA/1.3.0/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.3.0", "firmwares/NINA/1.3.0/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.4", "firmwares/NINA/1.2.4/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010", "Arduino NANO 33 IoT")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.4", "firmwares/NINA/1.2.4/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.3", "firmwares/NINA/1.2.3/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.3", "firmwares/NINA/1.2.3/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.2", "firmwares/NINA/1.2.2/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.2", "firmwares/NINA/1.2.2/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.1", "firmwares/NINA/1.2.1/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.2.1", "firmwares/NINA/1.2.1/NINA_W102-Uno_WiFi_Rev2.bin", true, 1000000, asList("Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.1.0", "firmwares/NINA/1.1.0/NINA_W102.bin", true, 1000000, asList("Arduino MKR WiFi 1010", "Arduino MKR Vidor 4000", "Arduino Uno WiFi Rev2")));
fwAvailable.add(new NinaFlasher("NINA firmware", "1.0.0", "firmwares/NINA/1.0.0/NINA_W102.bin", false, 1000000, asList("Arduino MKR WiFi 1010", "Arduino MKR Vidor 4000", "Arduino Uno WiFi Rev2")));

for (Flasher firmware : fwAvailable) {
getFirmwareSelector().addItem(firmware);
Expand All @@ -110,7 +106,7 @@ private void refreshCertList() {

@Override
protected void refreshSerialPortList() {
DefaultListModel<String> model = new DefaultListModel<String>();
DefaultListModel<String> model = new DefaultListModel<>();
BoardPort board;
listModel = new SerialPortListModel();
for (int i = 0; i < listModel.getSize(); i++) {
Expand Down Expand Up @@ -179,6 +175,7 @@ protected void testConnection() {

setEnabled(false);
new Thread() {
@Override
public void run() {
try {
fw.testConnection(port.getAddress(), fw.getBaudrate());
Expand All @@ -191,7 +188,7 @@ public void run() {
}
setEnabled(true);
resetProgress();
};
}
}.start();
}

Expand Down Expand Up @@ -240,7 +237,7 @@ public void run() {

@Override
protected void addCertificate() {
String website = (String) JOptionPane.showInputDialog(this, "Enter the website to fetch SSL certificate:",
String website = JOptionPane.showInputDialog(this, "Enter the website to fetch SSL certificate:",
"Add SSL certificate from website", JOptionPane.QUESTION_MESSAGE);
if (website.startsWith("http://")) {
JOptionPane.showMessageDialog(UpdaterImpl.this, "Sorry \"http://\" protocol doesn't support SSL",
Expand Down Expand Up @@ -288,6 +285,7 @@ protected void uploadCertificates() {

setEnabled(false);
new Thread() {
@SuppressWarnings("synthetic-access")
@Override
public void run() {
try {
Expand Down
22 changes: 16 additions & 6 deletions src/cc/arduino/plugins/wifi101/UpdaterJFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import cc.arduino.plugins.wifi101.flashers.Flasher;
import processing.app.Base;
import processing.app.Theme;

@SuppressWarnings("serial")
Expand All @@ -78,6 +78,7 @@ public class UpdaterJFrame extends JFrame {

public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
UpdaterJFrame frame = new UpdaterJFrame();
Expand All @@ -94,7 +95,7 @@ public UpdaterJFrame() {
int scale = Theme.getScale();
setTitle("WiFi101 / WiFiNINA Firmware/Certificates Updater");
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setBounds(100 * scale / 100, 100 * scale / 100, 500 * scale / 100, 520 * scale / 100);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
Expand Down Expand Up @@ -133,7 +134,7 @@ public UpdaterJFrame() {
gbc_textSelectPort.gridy = 0;
panel_1.add(textSelectPort, gbc_textSelectPort);

serialPortList = new JList<String>();
serialPortList = new JList<>();
JScrollPane sp = new JScrollPane(serialPortList);
serialPortList.setMaximumSize(new Dimension(300 * scale / 100, 100 * scale / 100));
GridBagConstraints gbc_serialPortList = new GridBagConstraints();
Expand All @@ -144,14 +145,15 @@ public UpdaterJFrame() {
gbc_serialPortList.gridheight = 5;
panel_1.add(sp, gbc_serialPortList);
serialPortList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
boolean enabled = (serialPortList.getSelectedIndex() != -1);
SelectBoardModule();
}
});

JButton refreshListButton = new JButton("Refresh list");
refreshListButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshSerialPortList();
}
Expand All @@ -165,6 +167,7 @@ public void actionPerformed(ActionEvent e) {

testConnectionButton = new JButton("Test connection");
testConnectionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
testConnection();
}
Expand All @@ -178,6 +181,7 @@ public void actionPerformed(ActionEvent e) {

openFirmwareUpdaterSketchButton = new JButton("Open Updater sketch");
openFirmwareUpdaterSketchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
openFirmwareUpdaterSketch();
}
Expand Down Expand Up @@ -215,7 +219,7 @@ public void actionPerformed(ActionEvent e) {
gbc_textSelectTheFirmware.gridy = 1;
panel.add(textSelectTheFirmware, gbc_textSelectTheFirmware);

firmwareSelector = new JComboBox<Flasher>();
firmwareSelector = new JComboBox<>();
GridBagConstraints gbc_firmwareSelector = new GridBagConstraints();
gbc_firmwareSelector.insets = new Insets(5, 5, 5, 0);
gbc_firmwareSelector.fill = GridBagConstraints.HORIZONTAL;
Expand All @@ -224,13 +228,15 @@ public void actionPerformed(ActionEvent e) {
panel.add(firmwareSelector, gbc_firmwareSelector);

firmwareSelector.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateCertSection();
}
});

updateFirmwareButton = new JButton("Update Firmware");
updateFirmwareButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateFirmware();
}
Expand Down Expand Up @@ -283,8 +289,9 @@ public void actionPerformed(ActionEvent e) {

certSelector = new JList<>();
certSelector.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
boolean enabled = (certSelector.getSelectedIndex() != -1);
boolean enabled = (getCertSelector().getSelectedIndex() != -1);
getRemoveCertificateButton().setEnabled(enabled);
}
});
Expand All @@ -299,6 +306,7 @@ public void valueChanged(ListSelectionEvent e) {

addCertificateButton = new JButton("Add domain");
addCertificateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addCertificate();
}
Expand All @@ -313,6 +321,7 @@ public void actionPerformed(ActionEvent e) {
removeCertificateButton = new JButton("Remove domain");
removeCertificateButton.setEnabled(false);
removeCertificateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeCertificate();
}
Expand All @@ -326,6 +335,7 @@ public void actionPerformed(ActionEvent e) {

uploadCertificatesButton = new JButton("Upload Certificates to WiFi module");
uploadCertificatesButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
uploadCertificates();
}
Expand Down
7 changes: 5 additions & 2 deletions src/cc/arduino/plugins/wifi101/WiFi101.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ public class WiFi101 implements Tool {

UpdaterImpl updater;

public void init(Editor editor) {
this.editor = editor;
@Override
public void init(Editor _editor) {
this.editor = _editor;
}

@Override
public String getMenuTitle() {
return "WiFi101 / WiFiNINA Firmware Updater";
}

@Override
public synchronized void run() {
if (updater == null)
try {
Expand Down
10 changes: 5 additions & 5 deletions src/cc/arduino/plugins/wifi101/certs/WiFi101Certificate.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ private static byte[] encodeTimestampV1(Date timestamp) throws IOException {

private static byte[] getSubjectValueHash(X509Certificate x509) throws NoSuchAlgorithmException, IOException {
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
ASN1InputStream ais = new ASN1InputStream(x509.getSubjectX500Principal().getEncoded());
while (ais.available() > 0) {
ASN1Primitive obj = ais.readObject();
sha1.update(extractPrintableString(obj));
try (ASN1InputStream ais = new ASN1InputStream(x509.getSubjectX500Principal().getEncoded())) {
while (ais.available() > 0) {
ASN1Primitive obj = ais.readObject();
sha1.update(extractPrintableString(obj));
}
}
ais.close();
return sha1.digest();
}

Expand Down
Loading

0 comments on commit b8aeea3

Please sign in to comment.